• VASCOdev
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies

At the moment, the only way I found out in order to create a lead and link it to a campaign in SalesForce via the API web service, is to first create the lead, and then create a campaignMember object which I link to the created lead (campaign id + lead id).

 

Question: is there a way to push the lead with the linked campaign all at the same time?

Hi there,

 

I'm using the salesforce webservice on .net platform to create leads in salesforce which works fine.

I recently added some code (see below) though to be able to add an existing campaign to my freshly created lead but I get the following error "insufficient access rights on cross-reference id". The user I'm logged in with the webservice has all the rights and permissions and should be able to do whatever he wants.

 

Can anyone help please, many thanks!

 

 

Lead lead = new Lead();

lead.Salutation = "Mr.";

lead.FirstName = "testfirstname";

lead.LastName = "testlastname";

lead.Email = "test@tester.com";

if (login())

{

SaveResult[] sr = binding.create(new sObject[] { lead });

foreach (SaveResult s in sr)

{

if (s.success)

{

errorLog.eventLog.Log("salesForce.createLead()", string.Format("Successfully created Lead in SalesForce with ID: {0}", s.id));

//***************************************************** CAMPAIGN ID *************************************************

CampaignMember campaignMember = new CampaignMember();

campaignMember.CampaignId = campaignID;

campaignMember.LeadId = s.id;

 

SaveResult[] srCmp = binding.create(new sObject[] { campaignMember });

foreach (SaveResult sc in srCmp)

{

if (!sc.success)

{

errorLog.eventLog.Log("salesForce.createLead()", string.Format("Error creating campaign to lead in SalesForce: {0}", sc.errors[0].message), System.Diagnostics.EventLogEntryType.Error);

}

}

//********************************************************************************************************************

}

else

{

errorLog.eventLog.Log("salesForce.createLead()", string.Format("Error creating Lead in SalesForce: {0}", s.errors[0].message),System.Diagnostics.EventLogEntryType.Error);

}

}

Message Edited by VASCOdev on 02-09-2010 11:58 PM