function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
voztele_devvoztele_dev 

Update a multipicklist with no values from java ??

Hi, i have created a custom field in the opportunity entity, the field's type is multipicklist and i want to update it (in some cases) with no values (clear the list).

I am able to update it when there are values to put in, but when i try to update with an empty string the old values persist and nothing is updated.

Example:

...
key = "custom_field";
value = ...
MessageElement messageElement = new MessageElement(key, value);
opp[0] = new SObject();
opp[0].setType("Opportunity");
opp[0].set_any(messageElements);
...
SaveResult[] sr = binding.update(opp);

when value is something like "first;second;third" (values separated by semicolons) it works fine, but when value is an empty string (value = "";) it does not work.

Am i missing something ? is there any restriction ?
What is the way to clear a multipicklist of an object ?

Any help will be appreciated


Best Answer chosen by Admin (Salesforce Developers) 
dkadordkador

Use the fieldsToNull array element (you can search the API docs for more information about this).

All Answers

dkadordkador

Use the fieldsToNull array element (you can search the API docs for more information about this).

This was selected as the best answer
voztele_devvoztele_dev

I will do it,

Thank you very much dkdor