While creating new lead from SDK in CRM 2016, I am passing statecode=1(Qualified) and statuscode=3(Qualified) but getting below exception. Could not figure out the root cause of it.
Requesting experts to help.
*This post is locked for comments
Hi,
Are you trying to create a lead with status as Qualified? If yes it won't work because by default crm create the record in open state. You could create the lead and then call set state post creation-
Sample code-
---------
using (service = new OrganizationServiceProxy(new Uri(_organizationURI), null, _credential, null))
{
var newLead = new Entity("lead");
newLead["subject"] = "new lead 1";
newLead["firstname"] = "Test";
newLead["lastname"] = "Last1";
var leadiId = service.Create(newLead);
SetStateRequest setStateRequest = new SetStateRequest();
setStateRequest.EntityMoniker = new EntityReference("lead", leadiId);
setStateRequest.State = new OptionSetValue(1);
setStateRequest.Status = new OptionSetValue(3);
service.Execute(setStateRequest);
}
---------
Hope this helps.
Please share you code.
Refer the standard code in below links. Advise you to check to which version of crm this code applies.
https://msdn.microsoft.com/en-us/library/hh547458.aspx
https://www.inogic.com/blog/2016/11/qualify-lead-using-web-api-in-dynamics-365/
I checked the statecode and statuscode are same what we got in vanilla version.
Also If you see I am passing statecode=1(Qualified) and statuscode=3(Qualified) which is what we have by default for lead.
I want to understand is there any thing which I am missing as I am trying to create lead status as Qualified.
Hi,
Based on the error message, the code is not setting the statecode 1, it is still setting the statecode as o (Open). Debug your code and see if the field statecode is correctly setting.
You can also share your code here for review.
Hope this helps.
Please check the available Statecodes and Status codes on lead in your environment. I think statecode and statuscode values are different in your environment.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156