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
BDSjimBDSjim 

Creating CampaignMember record, FirstRespondedDate goes blank and comes back and goes blank

I wrote a script that creates a CampaignMember for a Lead for when people respond to our web campaigns.  Since we already know who they are, they don't need to fill in the full lead form again.

I am using this code to create the CampaignMember for the Lead:

PHP Code:
  $sObject = new SObject();
$sObject->type = 'CampaignMember';
$fieldsToUpdate=array(
'CampaignId'=>$selected['campaignid'],
'LeadId'=>$found_id,
'Status'=>'Responded',
);
$sObject->fields = $fieldsToUpdate;
$newrec = $GLOBALS['sfconnection']->create(array($sObject));

 
The code creates the CampaignMember perfectly, but I was testing and found that if I "responded" to the same campaign a second time it would clear out the CampaignMember.FirstRespondedDate ... but then if I responded yet again, the FirstRespondedDate would appear again.  So, when "responding" to the campaign multiple times it looks like this:
1.  CampaignMember created, FirstRespondedDate is populated
2.  CampaignMember updated, FirstRespondedDate is erased
3.  CampaignMember updated, FirstRespondedDate is populated
4.  CampaignMember updated, FirstRespondedDate is erased
... and so on...

I could do a search and determine if i just need to update a field, but it seems like a lot of extra SOAP calls to execute when there is obviously already some trigger on the CampaignMember table checking for duplicates - maybe it could not erase the FirstRespondedDate. 

Am I making a mistake with something here?