Search code examples
iossalesforcesoql

Convert Leads to Opportunity using Salesforce sdk for iOS


I am creating iOS application with the integration of SalesForce. I have created Xcode project with steps mentioned. I am able to get list of Leads, Contacts, Account, etc.

I have one more feature regarding conversion of Leads into Opportunity. I'm searching for SOQL using which I can make this feature in work.

But not able to find out the correct way of doing this or link using which I can get it.

I found convertLead() but somehow I'm not getting it.

In my application, I am showing list of Leads and on selection of one lead I have given ability to user to convert it into Opportunity. I have shown form with the fields which are mandatory while conversion. But what will the SOQL for it?

Any one have idea about it? Where can I get information related to Saleforce sdk for iOS?

Thank you


Solution

  • You can build a custom Apex REST web service, and call that to convert your Lead:

    https://success.salesforce.com/answers?id=90630000000hLeeAAE

    Then build an SFRestRequest and set it's endpoint to your service

    SFRestRequest *request = [SFRestRequest requestWithMethod:SFRestMethodPOST path:@"" queryParams:nil];
    request.endpoint = @"/services/apexrest/{your endpoint}/{a lead Id}";
    [[SFRestAPI sharedInstance] sendRESTRequest:request failBlock:^(NSError *e){
                NSLog(@"error: %@", e);
            } completeBlock:^(id success){
                NSLog(@"success: %@", success);
            }];
    

    convertLead() is available in the SOAP API. I don't think it is possible to call convertLead directly from the REST API. If you'd like to use the SOAP API in your iOS application, use this library:

    https://github.com/superfell/zksforce