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
KOD123KOD123 

Add picklist values through API

Hello,

 

I have a multi picklist in the Account object and the values should be taken from an object which is external to SF.

 

I want that once I add a new value to this table which is external it will update the multi picklist value through API.

 

I wrote the following code as a simple example:

 

MetadataService ms = new MetadataService();

ms.SessionHeaderValue = new com.salesforce.metadata.SessionHeader();

ms.SessionHeaderValue.sessionId = lr.sessionId;

ms.Url = lr.metadataServerUrl;

 

 

Picklist expenseStatus = new Picklist();

PicklistValue Test1 = new PicklistValue();

Test1.fullName = "Test1";

PicklistValue Test2 = new PicklistValue();

Test2.fullName = "Test2";

PicklistValue Test3 = new PicklistValue();

Test3.fullName = "Test3";

PicklistValue Test4 = new PicklistValue();

Test4.fullName = "Test4";

expenseStatus.picklistValues = new PicklistValue[] { Test1, Test2, Test3, Test4 };

 

 

 

CustomField expenseStatusField = new CustomField();

expenseStatusField.fullName = "Members__c.Application_Progress__c";

expenseStatusField.label = "Application Progress";                   

expenseStatusField.type = FieldType.Picklist;                   

expenseStatusField.picklist = expenseStatus;

Metadata[] mdata = new Metadata[1];

mdata[0] = expenseStatusField;

 

AsyncResult[] ars =

ms.create(mdata);

 

 

I get the following error:

Status: ApiSalesF.com.salesforce.metadata.StatusCode.ALL_OR_NONE_OPERATION_ROLLED_BACK

Status Code: ApiSalesF.com.salesforce.metadata.AsyncRequestState.InProgress

 

Any suggestion?

altaiojokaltaiojok

The ALL_OR_NONE_OPERATION_ROLLED_BACK error should only be thrown via the Enterprise or Partner APIs, not the Metadata API. Do you know if you happen to be accidentally setting the AllOrNoneHeader SOAP header for this Metadata operation? I tried reproducing it, but was unable to.

Kman1976Kman1976

I am having same problem.Did you get a solution ?

Apex LearnerApex Learner

is there any way to edit picklist value through metadat API . 

I am current testing meta data API via SOAP ui and till now I am able to add picklist values .

but can not edit any perticuler picklist value 

 

eg . object : lead 

       field : number__c

  type : picklist

 

values : 1 , 2

 

any methode i can edit 1 to 11  ??