Skip to content

Fix Salesforce Multi-select Picklist with any REST API for a JSON insert and alleviate JSON_PARSER_ERROR

License

Notifications You must be signed in to change notification settings

romant/sfdc-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

###Situation

Attempting to save data into a Salesforce Multi-select Picklist with any REST API with a JSON object returns a

Cannot deserialize instance of multipicklist from START_ARRAY value

and

JSON_PARSER_ERROR

This looks to be due to the way Salesforce treats Array Elements with the JSON Object.

#####Example If you wish to create a new contact with a custom field Availability__c, you typically end up with:

{
  "FirstName": "Jeffrey",
  "LastName": "McKillop",
  "Availability__c": [
    "Monday",
    "Tuesday",
    "Friday",
    "Sunday"
  ]
}

What Salesforce is actually expecting:

{
  "FirstName": "Jeffrey",
  "LastName": "McKillop",
  "Availability__c": "Monday;Tuesday;Friday;Sunday"
}

######Differences Note that not only is the customer object no longer an array, but also the separator has to change to a ; (semi-colon)

To fix. Simply use the attached function for amend for a seamless Salesforce injestion.

###Usage

regUserJSON = fixSFDCString(regUserJSON, "Availability__c");

About

Fix Salesforce Multi-select Picklist with any REST API for a JSON insert and alleviate JSON_PARSER_ERROR

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published