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
Abhilash Mishra 13Abhilash Mishra 13 

How to Add and Replace values of picklist field through meta data api

Hi, 
I am Using php tooklit for intergration.
Is there any way I can replace , delete or add new picklist value to an Existing Picklist value.

This is very important for me. 
Regards
Abhilash Mishra
Tejas KardileTejas Kardile
Hi,

Please refer below salesforce article which will help you in adding picklist value through api

https://help.salesforce.com/apex/HTViewSolution?id=000002778&language=en_US

Thanks
Tejas KardileTejas Kardile
Please refer this article as well.
https://developer.salesforce.com/forums?id=906F000000092beIAA
Abhilash Mishra 13Abhilash Mishra 13
Hi Tejas,
Thanks.
I Tried php toolkit sample code  of creating a custom object and got this Error

Function ("create") is not a valid method for this service

Here is the code.
<?php
// SOAP_CLIENT_BASEDIR - folder that contains the PHP Toolkit and your WSDL
// $USERNAME - variable that contains your Salesforce.com username (must be in the form of an email)
// $PASSWORD - variable that contains your Salesforce.com password

//define("Force.com-Toolkit-for-PHP-master/soapclient/api_files/soapclient");
//require_once (Force.com-Toolkit-for-PHP-master/soapclient/SforcePartnerClient.php');
require_once ('Force.com-Toolkit-for-PHP-master/soapclient/SforceEnterpriseClient.php');
require_once ('Force.com-Toolkit-for-PHP-master/soapclient/SforceMetadataClient.php');
//require_once ('Force.com-Toolkit-for-PHP-master/soapclient/userAuth.php');


//$mySforceConnection = new SforcePartnerClient();
$mySforceConnection = new SforceEnterpriseClient();
//$mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/partner.wsdl.xml');
$mySoapClient = $mySforceConnection->createConnection('wsdl.jsp.xml');
$loginResult = $mySforceConnection->login($usename, $password);
echo "<pre>";
print_r($loginResult);
echo "</pre>";
$myMetadataConnection = new SforceMetadataClient('metadata.xml', $loginResult, $mySforceConnection);
echo "<pre>";
print_r($myMetadataConnection);
echo "</pre>";
try{
$customObject = new SforceCustomObject();
  $customObject->fullName = 'CustomObjFromPHP__c';
  $customObject->deploymentStatus = DEPLOYMENT_STATUS_DEPLOYED;

  $customObject->setDescription("A description");
  $customObject->setEnableActivities(true);
  $customObject->setEnableDivisions(false);
  $customObject->setEnableHistory(true);
  $customObject->setEnableReports(true);
  $customObject->setHousehold(false);
  $customObject->setLabel("My Custom Obj from PHP");
  $customField = new SforceCustomField();
  $customField->setFullName('MyCustomFieldb__c');
  $customField->setDescription('Description of New Field');
  $customField->setLabel('My Custom Field Label');
  $customField->setType('Text');

  $customObject->nameField = $customField;

  $customObject->pluralLabel = 'My Custom Objs from PHP';
  $customObject->sharingModel = SHARING_MODEL_READWRITE;

  print_r($myMetadataConnection->create($customObject));

} catch (Exception $e) {
  echo $myMetadataConnection->getLastRequest();
  echo $e->faultstring;
}
?>