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
birdofpreybirdofprey 

Handling Concurrency in PHP

I run into a problem where in one PHP page where I create a contact record and use that created record Id to assigned it to campaign record which it is updated.

 

Sometimes, it seems that it does an update of the campaign ahead of the create contact record.

 

The campaign then does not update the record with the newly contact record attach to it, because it seems as if record is still being process while the update to the campaign record is called.

 

example mockup of my code.

function createcontact(){
.....
  $sObject = new stdclass();
  $sObject->FirstName = 'Smith';
  $sObject->LastName = 'John';
  $createResponse = $mySforceConnection->create(array($sObject), 'Contact');

 return $createResponse->id;
}


  $sObject2 = new stdclass();
  $sObject2->Id = 111111111111;
  $sObject2->Contact__c = createcontact();
$response = $mySforceConnection->update(array ($sObject2), 'Campaign');