Never mind, I ended up just trying what I posted and yes it's created same as any other object.
(mike feel free to delete this post)
I was wondering if anyone was able to essentially log a task to a custom object via the API. I have a custom Lead__c object that I'd like to log tasks to it's activities. I'm using the partner api, do i create the Task object like I create any other object?
Any information would be much appreciated?
Never mind, I ended up just trying what I posted and yes it's created same as any other object.
(mike feel free to delete this post)
I am glad that you figured it out and there is no need to delete it, someone may ask you for help sometime with this.
~Mike
I'm actually struggling with this at the moment, I have other API functions (create/upsert) working well, but when I try and create a new task, I'm getting an error: Invalid SOAP header in SforceBaseClient.php on line 273.
I get this error regardless of whether I use the Partner or Enterprise client. I wonder if I need to use a specific header option? I used this in the past with ol' NuSOAP without any issue.
eg of my code below that is throwing the error (authentication works fine of course).
Thanks so much!
Chuck
PHP Code:require_once('soapclient/SforceEnterpriseClient.php');
/**
* explicitly turn off WSDL caching (toggling this makes no difference)
*/
ini_set('soap.wsdl_cache_enabled', 0);
// instantiate a new Salesforce Enterprise object
$crmHandle = new SforceEnterpriseClient();
// instantiate a SOAP connection to Salesforce
try {
$crmHandle->createConnection(SALESFORCE_WSDL);
} catch (Exception $e) {
// handle exception - did you set the WSDL path above?
// we may also be in a Salesforce outage right now
}
// log in to Salesforce
try {
$crmHandle->login(SALESFORCE_USER, SALESFORCE_PASS . SALESFORCE_TOKEN);
} catch (Exception $e) {
// handle exception - did you modify the credentials above to your own?
}
// create our task based on SFID as WhoID:
$task = array();
$task['WhoID'] = 'xxxxxxxxxxxxxxxxx';
$task['Description'] = 'the latest activity detail goes here';
$task['Status'] = 'Completed';
$task['Subject'] = 'Trial activity';
$task['OwnerID'] = 'xxxxxxxxxxxxxxxxx';
// create the task
$result = $crmHandle->create(array($task), 'Task');
Chuck,
I will take a look at this. I think that I actually have a demo task script somewhere on my server, but need to look for it.
I am getting ready to head to dreamforce and do not know when I will be able to look for it, probably tomorrow or Wednesday!!
~MIKE
I think I had a bad copy/paste in my security token. For future reference, this below works!
PHP Code:define('SALESFORCE_USER', 'username@domain.com');
define('SALESFORCE_PASS', '**********');
define('SALESFORCE_TOKEN', 'abcdefj123890');
define('SALESFORCE_WSDL', 'enterprise.wsdl.xml');
require_once('soapclient/SforceEnterpriseClient.php');
// instantiate a new Salesforce Enterprise object
$crmHandle = new SforceEnterpriseClient();
// instantiate a SOAP connection to Salesforce
try {
$crmHandle->createConnection(SALESFORCE_WSDL);
} catch (Exception $e) {
// handle exception - did you set the WSDL path above?
// we may also be in a Salesforce outage right now
}
// log in to Salesforce
try {
$crmHandle->login(SALESFORCE_USER, SALESFORCE_PASS . SALESFORCE_TOKEN);
} catch (Exception $e) {
// handle exception - did you modify the credentials above to your own?
}
// create our task based on SFID as WhoID:
$task = array();
$task['WhoID'] = 'xxxxxxxxSFIDgoesherexxxxx';
$task['Description'] = 'the latest activity detail goes here';
$task['Status'] = 'Completed';
$task['Subject'] = 'Trial activity';
$task['OwnerID'] = 'xxxxleadOWNERidgoesherexxx';
// create the task
// $task must be wrapped in an array, as create() can create
// many objects with a single API call
$result = $crmHandle->create(array($task), 'Task');
var_dump($result );
Glad you figured it out
Bookmarks