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
alivepjcalivepjc 

CampaignMember creation php urgent please!

Hi,

I am having problems creating elements, in this case is campaign members. I am using the files from the php sample kit which refer to the urn:partner.soap.sforce.com

I can query anything perfectly, but for create calls nothing happens. Please give me a hand. I have looked around the forum for hours and I can't figure it out.

I have the endpoint , campaign id and contact id coming from a form. variables are passed ok.

$client = new SalesforceClient($SESSION); // $SESSION passed as a $_POST from the previous form.
$client->_endpoint = $_POST['sf_endpoint']; // endpoint passed as a $_POST from the previous form.

 $FIELDS = array('type'=>'CampaignMember','CampaignId'=>'$camp_id','ContactId'=>'$contactid');
 $result = $client->create($FIELDS);

if (PEAR::isError($result)) {
    print "<p><span style=\"color:#FF0000\">".$result->getMessage()."<br /></span></p>";
}

this returns NO error, but nothing is created. Am I passing the correct requiered fields?

I am running PHP Version 4.3.10. If I need to post the soap response or xml response, can anybody show me how to do that please?

I appreciate your help!

alivepjc

P.S.: dreamforce 05 rocked!

adamgadamg
I'm guessing you are getting an error (missing field, etc) somewhere but that it isn't being propagated to PHP; can you get the raw SOAP messages and post them here (there are examples for doing that in PHP somewhere on the boards..)
alivepjcalivepjc

I'm calling this:

echo "Response: ".$client->__getlastresponse()."\n";

right after my create call:

$FIELDS = array('type'=>'CampaignMember','CampaignId'=>'$camp_id','ContactId'=>'$contactid');
 $result = $client->create($FIELDS);

I need to have created the soapClient with the trace option to 1.

SalesforceClient extends WebService_SforceService_Soap which extends SOAP_Client... how do I set the option to trace after creating the client ?

$client = new SalesforceClient($SESSION);
$client->_endpoint = $_POST['sf_endpoint'];

so basically my code looks like this:

$client = new SalesforceClient($SESSION);
$client->_endpoint = $_POST['sf_endpoint'];

$FIELDS = array('type'=>'CampaignMember','CampaignId'=>'$camp_id','ContactId'=>'$contactid');
 $result = $client->create($FIELDS);

echo "Response: ".$client->__getlastresponse()."\n";

If it can't be done, what do I need to change in which file? I can't seem to find it anywhere in the boards.

thank you very much!

alivepjcalivepjc

got it!

$client = new SalesforceClient($SESSION);
$client->_endpoint = $_POST['sf_endpoint'];
$client->__trace(1);

  $FIELDS = array('type'=>'CampaignMember','CampaignId'=>$camp_id,'ContactId'=>$contacts);
 $result = $client->create($FIELDS);

echo "Response: ".$client->__getlastresponse()."\n";

SynchroSynchro
I may be mistaken here, but I think you're using partner-style syntax in that example. If you can decipher this thread I started, you'll find that there's some working enterprise-style syntax that works:

http://forums.sforce.com/sforce/board/message?board.id=PerlDevelopment&message.id=644
alivepjcalivepjc
there were actually 2 problems I was trying to fix, one was the object creation and the other one was getting the soap response to see the error in the object creation. I got both resolved. I am working with the partner wsdl, so no worries!