I'm using the PHP Toolkit for integrating a web application with my Salesforce account. I have this custom object:
Individual__Choice__c
that contains this custom Picklist
:
Primary_Option__c
This Picklist
currently has 15 or so options and I'd like to add a 16th. I've looked here and here and attempted to modify for my own use as follows:
$sfConnection = new SforceEnterpriseClient();
$sfConnection->createConnection(ENTERPRISE_WSDL);
$loginResult = $sfConnection->login(USERNAME , PASSWORD . TOKEN);
$sfMetadataConnection = new SforceMetadataClient(METADATA_WSDL, $loginResult, $sfConnection);
$customField = new SforceCustomField();
$customField->setFullName('Individual_Choice__c.Primary_Option__c');
$customField->setDescription('New Option Field');
$customField->setLabel('New Label');
$customField->setType('Picklist');
$sfMetadataConnection->create($customField);
But to no avail. I get this error:
Function ("create") is not a valid method for this service
I've also tried:
$sfConnection = new SforceEnterpriseClient();
$sfConnection->createConnection(ENTERPRISE_WSDL);
$loginResult = $sfConnection->login(USERNAME , PASSWORD . TOKEN);
$sfMetadataConnection = new SforceMetadataClient(METADATA_WSDL, $loginResult, $sfConnection);
$obj = new SforceCustomObject();
$obj->currentName = 'Individual_Choice__c.Primary_Option__c'';
$obj->metadata = new SforceCustomField();
$obj->metadata->fullName = 'Individual_Choice__c.Primary_Option__c'';
$obj->metadata->type = 'Picklist';
$obj->metadata->picklist = new stdClass();
$obj->metadata->picklist->picklistValues = [];
$obj->metadata->picklist->picklistValues[0] = new stdClass();
$obj->metadata->picklist->picklistValues[0]->label = 'New Label';
$obj->metadata->picklist->picklistValues[0]->value = 'New Value';
$result = $sfMetadataConnection->update($obj);
But, again, I get a similar error:
Function ("update") is not a valid method for this service
I know I'm able to successfully make the metadata client connection because if I var_dump
at that point in my code I get a valid object.
Any idea of how I can properly accomplish this using PHP?