Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- General Development
- :
- Creating Campaign Members with PHP Toolkit
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Creating Campaign Members with PHP Toolkit
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-14-2012 07:48 AM - edited 12-14-2012 08:00 AM
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($sObje ct);
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?

