+ Start a Discussion
brumbrum 

How to get deleted records from Contacts using ios

Hi,

 

I need to retrieve only deleted records from Contacts using ios to synchronize data with my ipad application. I am trying a query which I check isDeleted = true, but it doesn't work. In java api, we have a getDeleted() method to simplify our life. Someone know, what is an equivalent method or something that works fine?

 

Thanks,

brum

J2theCJ2theC

To get deleted records, you need to use the querymore feature of the API. Unfortunately, this feature is not available on the REST API. You will need a SOAP implementation in order to archieve this.

 

 

edit: the actual call is queryall(), not querymore()

brumbrum

Hi J2theC,

 

Do you have an example or a link to explain more about this subject? I remind you that I develop a mobile iOS app (ipad) based on SalesforceMobileSDK-iOS.

 

Thanks,

brum

J2theCJ2theC

When i was searching this information, I've found it using the following link: 

 

http://boards.developerforce.com/t5/REST-API-Integration/Query-All-using-REST-API/td-p/354341

 

 

You can find information about queryall() on the following link: http://www.salesforce.com/us/developer/docs/api/index_Left.htm

search for: queryall

brumbrum

Thanks J2theC. I used zkSforce queryAll() method with hardcode userId and password and it works fine. But now, I have another issue to finish my requirement. How to get current userId and password from my whole ipad application based on SalesforceMobileSDK-iOS (REST API)?

J2theCJ2theC

You can't. The REST toolkit uses OAuth, so you don't have access to the password. You need to use OAuth with the SOAP toolkit.

SuperfellSuperfell

You can use your access_token obtained via OAuth with the soap API, just stick it in the sessionHeader.

SuperfellSuperfell

Oh, and BTW, queryAll is not the same as getDeleted(), if you need to reliably find deleted records getDeleted is the only way to do it. (not all records are soft deleted in all circumstances, so queryAll can miss some)

brumbrum

I will explain my case with more details.

 

1) I am already logged using SalesforceMobileSDK-iOS (REST API) and I start to synchronize ipad with Salesforce.

2) I need to verify deleted contacts. So, I did that:

 

    ...

    ZKSforceClient *sforce = [[ZKSforceClient alloc] init];
    [sforce login:myLoginString password:myPasswordString];    <---- HERE IS THE PROBLEM

    ZKQueryResult *qr = [sforce queryAll:@"SELECT LastName, FirstName, Email, IsDeleted FROM Contact WHERE IsDeleted=true"];

    ...

    handle qr

 

3) I am trying to replace line "HERE IS THE PROBLEM" to current user authentication using code below, but it does not work. I got an error SIGABRT in the SELECT line.

 

     ...

    ZKSforceClient *sforce = [[ZKSforceClient alloc] init];
    NSString *clientId = [self remoteAccessConsumerKey];
    NSString *redirectUri = [self oauthRedirectURI];
    [sforce loginFromOAuthCallbackUrl:redirectUri oAuthConsumerKey:clientId];

    ZKQueryResult *qr = [sforce queryAll:@"SELECT LastName, FirstName, Email, IsDeleted FROM Contact WHERE IsDeleted=true"]; <--- ERROR HERE

    ...

    handle qr

 

Thanks.

 

SuperfellSuperfell

You can provide your own impl of ZKAuthenticationInfo that returns the accessToken from the ios toolkit for zkSforce to use.

brumbrum

I already have got accessToken and redirectURI, because they are constants in my AppDelegate. I think the problem is to try [sforce loginFromOAuthCallbackUrl:redirectUri oAuthConsumerKey:clientId]; and then I got error in the select line because I am not logged correctly. Please, show me with examples, if possible.