+ Start a Discussion
DarkHalfDarkHalf 

I just want to create a lead.... native mobile sdk

I've been looking at the SQLAggrigator for hours now.  I can query just fine, but insert doesnt work.  Is there any possible way to insert a record into the leads/contacts from the native mobile sdk?

Best Answer chosen by Admin (Salesforce Developers) 
bhariharanbhariharan

Sorry - I was mislead to believe that you were using SmartStore, since you mentioned that you were looking at SQLAggregator. You can find the latest doc here. Also, take a look at the RestAPIExplorer app. This is a native sample app that gives you a visual interface to create/update/query/delete objects, or run any REST request for that matter, against a Salesforce endpoint. I'm guessing you will need to create an object of type 'Lead' or 'Contact'. 'Contact__c' is a custom object, and I can't really speak to what type of object that is without having metadata of the org you're testing against.

All Answers

bhariharanbhariharan

Are you trying to insert data into SmartStore, in your native Android app? The upsert() method in the SmartStore class can be used to accomplish this. For an example on usage, take a look at the SmartStoreInterface class in the NativeSqlAggregator sample app (specifcally, at the insertAccount() and insertOpportunity() methods).

 

DarkHalfDarkHalf

I'm using iOS.  I dont see a smartstore example

bhariharanbhariharan

iOS also has a sample app called NativeSqlAggregator. Are you using 'forceios' through npm or getting the source from GitHub? Which version of the Mobile SDK are you using?

DarkHalfDarkHalf

I think i found it.  This seems to work:

 

NSString * objectType = @"Contact__c";
    NSDictionary *fields=[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"Test 1", nil] forKeys:[NSArray arrayWithObjects:@"Name", nil]];
    SFRestRequest *TestAdd = [[SFRestAPI sharedInstance] requestForCreateWithObjectType:objectType fields:fields];
    
    [[SFRestAPI sharedInstance] send:TestAdd delegate:self];

 

DarkHalfDarkHalf

Although this adds "something" to a "contact" section, it doesnt actually add a person to the contacts list... any thoughts?

bhariharanbhariharan

The code you have has nothing to do with SmartStore. It is making a REST request to create a custom object of type 'Contact__c'. Are you trying to insert into SmartStore, or create objects on your org using REST?

DarkHalfDarkHalf

You'll have to forgive me however the documentation is rather lacking.

 

I'll reiterate:  I am using the native ios SDK.  I found examples to use the restapi part of ios sdk for salesforce.  I have no clue what SmartStore is, and cannot find any examples of SmartStore on ios.

 

I want to add a lead into my salesforce leads section (or a contact).    When i use the code above, it inserts something into salesforce that calls itself a "Contact" but has some heart icon and has nothing but a name (nor does it show up in the contacts secion).

 

 

bhariharanbhariharan

Sorry - I was mislead to believe that you were using SmartStore, since you mentioned that you were looking at SQLAggregator. You can find the latest doc here. Also, take a look at the RestAPIExplorer app. This is a native sample app that gives you a visual interface to create/update/query/delete objects, or run any REST request for that matter, against a Salesforce endpoint. I'm guessing you will need to create an object of type 'Lead' or 'Contact'. 'Contact__c' is a custom object, and I can't really speak to what type of object that is without having metadata of the org you're testing against.

This was selected as the best answer
DarkHalfDarkHalf

What you said lead me to the correct solution.  I had to look up the SOQL document for lead and contact and use those fields.