You need to sign in to do that
Don't have an account?
Native iOS having trouble upserting to SFDC
Hello - Not quite sure if the title is most applicable, but here is the issue my team is having.
Our iOS app uses Core Location to identify a street address. It then searches for that street address in Salesforce, under both the Leads and the Accounts. Data can be input on the device, and then the information is uploaded back to Salesforce.
We normally don't get issues with the app, however, and this is the real kicker - it refuses to work in our main office.
Does anyone have any pointers as to what may be causing the error? I've included the Console output below. Sorry if it is more than what is required.
Mar 5 15:19:27 Redacted-Name-iPad Sequoia[9181] <Warning>: ( "<SFAccount: 0x1e034c10> (entity: SFAccount; id: 0x1e07f900 <x-coredata://B05E5782-65F4-4EBB-9E68-F4E8D2C173FA/SFAccount/p5> ; data: <fault>)" ) Mar 5 15:19:29 Redacted-Name-iPad Sequoia[9181] <Warning>: is connected: 1 Mar 5 15:19:29 Redacted-Name-iPad Sequoia[9181] <Warning>: SFRestAPI::send: <SFRestRequest 0x1e0506d0 endpoint: /services/data method: GET path: /v23.0/query queryParams: { "q" : "SELECT ID, Company, Name, Street, City, State, PostalCode, Phone FROM Lead WHERE PostalCode = '15238' AND Street LIKE '90 Beta_%' AND City = 'O'Hara Township' AND State = 'PA'" } > Mar 5 15:19:29 Redacted-Name-iPad Sequoia[9181] <Warning>: error: Error Domain=com.salesforce.RestAPI.ErrorDomain Code=999 "The operation couldn’t be completed. (com.salesforce.RestAPI.ErrorDomain error 999.)" UserInfo=0x1e0ac010 {message= 'O'Hara Township' AND State = 'PA' ^ ERROR at Row:1:Column:175 line 1:175 mismatched character '<EOF>' expecting ''', errorCode=MALFORMED_QUERY} Mar 5 15:19:29 Redacted-Name-iPad Sequoia[9181] <Warning>: request:didFailLoadWithError: Error Domain=com.salesforce.RestAPI.ErrorDomain Code=999 "The operation couldn’t be completed. (com.salesforce.RestAPI.ErrorDomain error 999.)" UserInfo=0x1e0ac010 {message= 'O'Hara Township' AND State = 'PA' ^ ERROR at Row:1:Column:175 line 1:175 mismatched character '<EOF>' expecting ''', errorCode=MALFORMED_QUERY} Sequoia[9181] <Warning>: ( ) Mar 5 15:26:47 Redacted-Name-iPad locationd[46] <Notice>: received EBUSY, try kScanTypeChannel, channel, 153, rssi -60, delayed 0.000s Mar 5 15:26:51 Redacted-Name-iPad Sequoia[9181] <Warning>: ( "<SFAccount: 0x1e034c10> (entity: SFAccount; id: 0x1e07f900 <x-coredata://B05E5782-65F4-4EBB-9E68-F4E8D2C173FA/SFAccount/p5> ; data: {\n accountType = Prospect;\n autoRenewTerm = nil;\n billingCity = nil;\n billingState = nil;\n billingStreetAddress = nil;\n billingZIP = nil;\n businessName = \"Brock's Account\";\n contact = \"0x1cde1c30 <x-coredata://B05E5782-65F4-4EBB-9E68-F4E8D2C173FA/Contact/p5>\";\n contractDate = \"2013-01-18 05:00:00 +0000\";\n contractSignatureImageURL = nil;\n contractTerm = nil;\n createdContactID = nil;\n createdContractURL = nil;\n currentHauler = nil;\n dateCreated = \"2013-03-05 19:40:22 +0000\";\n dateModified = nil;\n latitude = 0;\n longitude = 0;\n opportunity = \"0x1cd99420 <x-coredata://B05E5782-65F4-4EBB-9E68-F4E8D2C173FA/Opportunity/p5>\";\n sfID = 001U000000Vm4LAIAZ;\n shippingCity = \"O'Hara Township\";\n shippingState = PA;\n shippingStreetAddress = \"90 Beta Dr\";\n shippingZIP = 15238;\n})" )
When you build your SOSL string, you need to escape the ' in strings, from the log, it shows
Take a close look at the city clause its City = 'O'hara Township' the ' in the city name needs to be escaped with \ when you build the string.
Understood, just had this problem turn up when doing a literal string in a different service.
Any idea how to programatically escape the apostrophe when I dont really know what the City value will be?
sure see escapeSosl in this class for an example, you'd call this passing each value as you build your sosl string.
Is it the API that limits that apostrophe? Or Obj-C?
I know for a fact they are able to be entered into text fields in Salesforce.
Either way, thanks for the link. I'm trying to learn how that works to patch my app.
Its from the sosl language, as quote is a delimitor in the sosl language, you can't have one directly within a value as then it thinks its the end of the value, same sort of thing as when building SQL queries.
So this is a bit embarassing, but I've been going at this for over an hour now and cannot seem to get this to work properly.
I'm trying to start just by using escapeSosl for the 'city' in my address fields. However, my setup is a bit different than what was in the Maildrop example.
Any further advice on how to properly implement this to cut out any apostrophes in 'city' ?
Where are you building the sosl string and calling search ? that's the place to do the escaping.
With the location string, I guess you are getting it right ! But with SOSL you need to check certain other parameters of IOS that can be helpful in building the rest query for your DB. Doc reference for each string of IOS upsertion can be found here