Hi,
Does anyone has php sample code for http://www.pocketsoap.com/weblog/2008/09/1824.html (also see the example upsert() - Foreign Keys section in the manual).
I worked this one out. I am updating a Task a linking it to an account using a custom account key Publisher_NUM__c.
Here is the code snippet that create the sObject:
$sfData = array('Subject' => $this->subject, 'Description'=>$this->description, 'Status' => 'Completed', 'Type__c' => $this->type //I have a custom type on the Task );
$sObject = new SObject(); $sObject->fields = $sfData; $sObject->type = 'Task';
$sObject->fields['What'] = "<type>Account</type><Publisher_NUM__c>$sfAccount</Publisher_NUM__c>"; //$sfAccount the the value of my account foreign key
I user a SF create(array($sObject)) call. You can also use upsert if you have your custom primary key on Task.
I worked this one out. I am updating a Task a linking it to an account using a custom account key Publisher_NUM__c.
Here is the code snippet that create the sObject:
$sfData = array('Subject' => $this->subject, 'Description'=>$this->description, 'Status' => 'Completed', 'Type__c' => $this->type //I have a custom type on the Task );
$sObject = new SObject(); $sObject->fields = $sfData; $sObject->type = 'Task';
$sObject->fields['What'] = "<type>Account</type><Publisher_NUM__c>$sfAccount</Publisher_NUM__c>"; //$sfAccount the the value of my account foreign key
I user a SF create(array($sObject)) call. You can also use upsert if you have your custom primary key on Task.
Here is the code snippet that create the sObject:
$sfData = array('Subject' => $this->subject,
'Description'=>$this->description,
'Status' => 'Completed',
'Type__c' => $this->type //I have a custom type on the Task
);
$sObject = new SObject();
$sObject->fields = $sfData;
$sObject->type = 'Task';
$sObject->fields['What'] = "<type>Account</type><Publisher_NUM__c>$sfAccount</Publisher_NUM__c>"; //$sfAccount the the value of my account foreign key
I user a SF create(array($sObject)) call. You can also use upsert if you have your custom primary key on Task.
All Answers
I've been struggling with the same thing. Can anybody help? For now I'm using triggers, but there's got to be an cleaner solution right?
Thanks in advance!
Here is the code snippet that create the sObject:
$sfData = array('Subject' => $this->subject,
'Description'=>$this->description,
'Status' => 'Completed',
'Type__c' => $this->type //I have a custom type on the Task
);
$sObject = new SObject();
$sObject->fields = $sfData;
$sObject->type = 'Task';
$sObject->fields['What'] = "<type>Account</type><Publisher_NUM__c>$sfAccount</Publisher_NUM__c>"; //$sfAccount the the value of my account foreign key
I user a SF create(array($sObject)) call. You can also use upsert if you have your custom primary key on Task.