You need to sign in to do that
Don't have an account?
PS81
Metadata API : dynamic picklist update - picklistvalue in a loop
I had retrieved the list of user names that is to be updated via metadata api to the custom picklist in the sobj 'contact'. Question is how do i update the picklist values in the loop?
MetadataAPIService.MetadataPort service = createService(); service.SessionHeader.sessionId = sessionId; MetadataAPIService.CustomField customField = new MetadataAPIService.CustomField(); customField.fullName = 'Contact.Test__c'; customField.label = 'Test'; customField.type_x = 'Picklist'; //customField.type = 'Picklist'; metadataAPIservice.Picklist sown = new metadataAPIservice.Picklist(); sown.sorted= false; metadataAPIservice.PicklistValue pval = new metadataAPIservice.PicklistValue(); pval.fullName= 'SHP Picked'; pval.default_x=false ; // Get the user list list<user> users = getUserList(); for (User usr:users){ //what to do in to insert the list into picklistValues? } sown.picklistValues = new List<MetadataAPIService.PicklistValue>{pval};
I believe you can define an empty list of type MetadataAPIService.PicklistValue prior to the for loop like this:
Then on line 15 you'd basically be copying lines 9-11:
After the for loop you can add pval to the dynamicPVals list and update line 17 to use this list:
Hope that helps,
Scott
All Answers
I believe you can define an empty list of type MetadataAPIService.PicklistValue prior to the for loop like this:
Then on line 15 you'd basically be copying lines 9-11:
After the for loop you can add pval to the dynamicPVals list and update line 17 to use this list:
Hope that helps,
Scott
thanks again!