You need to sign in to do that
Don't have an account?
MetaWhat
Does the Metadata API update feature work with Picklists?
Running into a rather frustrating problem with using the Metadata API to update a Picklist field.
The first problem is that the API requires that you provide the PickList values when performing an update even though you may not need to change the pick list values.
Second, when you provide the PickList values (using the same syntax that works with a create) you get an error saying "INVALID_FIELD" error with the message "Failed to create picklist value:<picklist value>".
Above is the code that doesn't work.
If I change this into a create action (changing UpdateMetadata out for Metadata and calling the create) it creates the field without a problem.
I am guessing it might be something to do setting the full name on the PicklistValue object but I tried all the variations that I could think of (<custom object>.<field>.<picklist value>, <field>.<picklist value>, ect) and couldn't get it to take.
So if it does work then I am missing something,
Any one gotten this to work and if so any examples of what is working?
Thanks for any help.
The first problem is that the API requires that you provide the PickList values when performing an update even though you may not need to change the pick list values.
Second, when you provide the PickList values (using the same syntax that works with a create) you get an error saying "INVALID_FIELD" error with the message "Failed to create picklist value:<picklist value>".
Code:
CustomField cfStatus = new CustomField(); cfStatus.setFullName("MyExistingObj.Status__c"); cfStatus.setDescription("The Status"); cfStatus.setType(FieldType.Picklist); cfStatus.setLabel("Status"); Picklist pl = new Picklist(); PicklistValue [] statusValues = new PicklistValue [] {new PicklistValue("Saved",false)}; pl.setPicklistValues(statusValues); cfStatus.setPicklist(pl); UpdateMetadata updateMetadataStatus = new UpdateMetadata(); updateMetadataStatus.setMetadata(cfStatus); updateMetadataStatus.setCurrentName("MyExistingObj.Old_Status__c");
sfdc.update (new UpdateMetadata [] {updateMetadataStatus});
If I change this into a create action (changing UpdateMetadata out for Metadata and calling the create) it creates the field without a problem.
I am guessing it might be something to do setting the full name on the PicklistValue object but I tried all the variations that I could think of (<custom object>.<field>.<picklist value>, <field>.<picklist value>, ect) and couldn't get it to take.
So if it does work then I am missing something,
Any one gotten this to work and if so any examples of what is working?
Thanks for any help.
Hi ,
I am working on Metadata API ,But not able to get some examples with C#,I saw your code its really very new can you provide me some code examples for Metadata APIs with C# or any url to get these type of example code. Specially I am looking for Deploy and Retrieve.
I will be really thankful to you.
I would not expect much from there documentation of the metadata api. It is poorly documented and I had to guess and play with alot of things to get them to work.
BTW, according to salesforce developers the update of picklist is not working at the moment.
Thanks,
Jon