I have successfully been able to add a new value to the Picklist for
Lead.LeadSource using the PHP Toolkit on the MetaData API using the following:
$sfm = new SforceMetadataClient(...) $obj = new SforceCustomObject(); $obj->currentName = 'Lead.LeadSource'; $obj->metadata = new SforceCustomField(); $obj->metadata->fullName = 'Lead.LeadSource'; $obj->metadata->type = 'Picklist'; $obj->metadata->picklist = new stdClass(); $obj->metadata->picklist->sorted = false; $obj->metadata->picklist->picklistValues = array(); $obj->metadata->picklist->picklistValues = new stdClass(); $obj->metadata->picklist->picklistValues->default = false; $obj->metadata->picklist->picklistValues->fullName = 'Test Source'; $result = $sfm->update($obj);
This however doesn’t filter down to any of the RecordTypes.
I’ve now spent several hours to rework the above code to try and get it to update the individual record types that extend Lead. I have also tried to adapt the Java code provided for RecordType Object into PHP with no success.
Is there anyway to achieve what I am trying to do?
(If you know the PHP that would be really handy too)
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Phil, what you are doing in your code is adding available Picklist values to the
LeadSource field. To actually assign combinations of Picklist values to different Lead RecordTypes, you will need to add these Picklist field values to the various Lead record types. To do this you will have to modify each Lead RecordType’s valid Picklist values.
The chain for this is:
- Get the
- Get its
RecordTypesproperty, a list of
RecordTypeobjects for the
- Find the appropriate
RecordTypefrom that list.
- Get this
PicklistValuesproperty, a list of
- Modify the
RecordTypePicklistValuerecords as appropriate, adding values to each
See the Metadata API Documentation for the RecordType object for more detail on the objects involved here.
Also, you may need to make the appropriate Lead RecordTypes available to different Profiles.