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
VASCOdevVASCOdev 

Create lead and add a campain to it using webservice

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
AlwaysConfusedAlwaysConfused

"Where does the error occur?" would be my first question...

 

If it's creating the lead I would check field level permissions in SF for the lead object.

If it's creating the CampaignMember record I would check those field level permissions.

 

Are you absolutely sure you can edit / create these objects with the given credentials?