Answered by:
Creating Campaign Response

Question
-
Hi there,
I am trying to create the campaign response using web services. Below is the code i am using. I am getting the error "The request could not be processed". Please advice.public static void AddCampaignResponse(string ContactId, string CampaignId,string phone) { CrmService service = GetCrmService(ConfigurationSettings.AppSettings["organization"], ConfigurationSettings.AppSettings["server"]); int rCode = 1; try { Guid cid = new Guid(ContactId); campaignresponse response = new campaignresponse(); Picklist rc = new Picklist(); rc.Value = rCode; Microsoft.Crm.SdkTypeProxy.activityparty[] ap = new Microsoft.Crm.SdkTypeProxy.activityparty[1]; ap[0] = new activityparty(); ap[0].partyid = new Lookup(); ap[0].partyid.type = EntityName.contact.ToString(); ap[0].partyid.Value = new Guid(ContactId); response.customer = ap; response.telephone = phone; response.responsecode = rc; Guid crid = new Guid(); crid = service.Create(response); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
Monday, May 11, 2009 10:12 PM
Answers
-
Hi.
A've tested your code.
One code line is missing:
response.regardingobjectid = new Lookup(EntityName.campaign.ToString(), new Guid(CampaignId));
After addition this line - everything works fine.
Truth opens to prepared mind. My blog - http://a33ik.blogspot.com- Proposed as answer by Andrii ButenkoMVP, Moderator Tuesday, May 12, 2009 10:27 AM
- Marked as answer by LearnQuick Tuesday, May 12, 2009 6:09 PM
Tuesday, May 12, 2009 10:25 AMModerator
All replies
-
Hi.
For detailed eception information add following:
try
{
...
}
catch(SoapException sexc)
{
throw new Exception(sexc.Detail.InnerText);
}
this code will give detailed information about occuring exception.
Truth opens to prepared mind. My blog - http://a33ik.blogspot.comTuesday, May 12, 2009 4:27 AMModerator -
Hi.
A've tested your code.
One code line is missing:
response.regardingobjectid = new Lookup(EntityName.campaign.ToString(), new Guid(CampaignId));
After addition this line - everything works fine.
Truth opens to prepared mind. My blog - http://a33ik.blogspot.com- Proposed as answer by Andrii ButenkoMVP, Moderator Tuesday, May 12, 2009 10:27 AM
- Marked as answer by LearnQuick Tuesday, May 12, 2009 6:09 PM
Tuesday, May 12, 2009 10:25 AMModerator -
I found my mistake. I was not associating the campaign response with any of the regardingobject id
Thanks alot guys!- Marked as answer by LearnQuick Tuesday, May 12, 2009 3:02 PM
- Unmarked as answer by LearnQuick Tuesday, May 12, 2009 6:08 PM
Tuesday, May 12, 2009 3:02 PM -
I found my mistake. I was not associating the campaign response with any of the regardingobject id
Yes =) i've checked and write as a solution 5 hours before you =)
Thanks alot guys!
Truth opens to prepared mind. My blog - http://a33ik.blogspot.comTuesday, May 12, 2009 6:07 PMModerator -
Yes you are right. I had that window open for a while so was not aware you had replied. I have marked your reply as answer.
Thanks again!Tuesday, May 12, 2009 6:09 PM