Reply
Newbie
DAWTSF
Posts: 1
0

Creating Campaign Members with PHP Toolkit

[ Edited ]

I have a lead allocating script that assigns the lead to a Sales Rep (from profiles & login date) in order.    I'm tasked with adding the incomming lead to a campaign.     From my understanding, to do this I need to create a campaign member to link the lead to the campaign but I'm running into some issues creating the campaign member.

 

 

The function that creates the campaign member:

 

[PHP]

function createCampaignMember($campaignId, $leadId){
	echo "<br>Campaign ID:".$campaignId;
	echo "<br>Lead ID:".$leadId;
	$sObject = new SObject();
	$sObject->type ='CampaignMember';
	$sObject->fields = array('CampaignId' => $campaignId, 'LeadId' => $leadId);
	try{
		$repsonse=$this->mySforceConnection->create($sObject);
		print_r($repsonse);
	} catch (exception $e){
		print_r($e);
	}
}

 

[OUTPUT] 
Campaign ID:701a0000000Zu1hAAC 
Lead ID:00Qa0000012cYoYEAU 

Array ( [0] => stdClass Object ( [errors] => Array ( [0] => stdClass Object ( [message] => Attempted to add a campaign member where either the member id 'null' or the campaign id 'null' is null. [statusCode] => REQUIRED_FIELD_MISSING ) ) [id] => [success] => ) )

 

 

Does anyone have any ideas why this would be happening?