Hi I'm building a preference center and I can update fields in Salesforce two ways. The documentation shows to use SET @result = UpdateSingleSalesforceObject but I was able to update a field without using SET @result. Do I need SET @result?

This is what I have and both ways work

  set @result = UpdateSingleSalesforceObject('Lead',@CaseSafeID,'MobilePhone',@MobilePhone)
  set @result = UpdateSingleSalesforceObject('Lead',@CaseSafeID,'Subscribe_to_SMS_Messages__c',@SMSOptIn)

  • Do you care if the update was successful? – Adam Spriggs Oct 11 '17 at 16:13
  • Yes I was planning to add those checks at some point – garek007 Oct 11 '17 at 16:50
  • It returns 1 for success or 0 for failure. – Bo Hu Oct 12 '17 at 1:10
  • So I need to use that if I want to see if the update was successful? – garek007 Oct 12 '17 at 13:52
  • 1
    You don't need to do all those updates separately. You can just add them as a list of name/values. ------ex.------ SET @result = UpdateSingleSalesforceObject('Lead',@CaseSafeID,'MobilePhone',@MobilePhone,'Subscribe_to_SMS_Messages__c',@SMSOptIn,'FirstName',@FirstName) – victorcorey Nov 2 '17 at 16:50

The UpdateSingleSalesforceObject() returns 1 for success or 0 for failure. So if you want to validate if the update was successful you should store the return value in a variable (ex. @result).

In addition you can update multiple fields at once by passing in a series of name/value pairs.

SET @result = UpdateSingleSalesforceObject('Lead',@CaseSafeID,'MobilePhone‌​',@MobilePhone,'Subs‌​cribe_to_SMS_Message‌​s__c',@SMSOptIn,'Fir‌​stName',@FirstName)
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.