web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Plugin Create 2 records when executing and execute properly when debugging

(0) ShareShare
ReportReport
Posted on by 3,634

Following piece of code needed simply to create a records in CRM when an order is posted. It works well while debugging. But when I stop profiling and let the plugin to execute it executed well and creates couple of records instead of one. Not sure, what is the problem with this snippet, any suggestion to dig out the problem?

private static void createOrderStatusHistory(IOrganizationService service,string status, Guid ownerId, Guid orderId)
{
	Entity osHistory = new Entity("new_statushistory");
	//new_orderstatus
			   if (status == "Muni")
	{
		osHistory["new_orderstatus"] = "Municipals Ordered";
	}
	else {
		osHistory["new_orderstatus"] = "Abstract Ordrered ";
	}

	osHistory["new_orderstatuschangedate"] = DateTime.Now;

	osHistory.Attributes.Add("ownerid", new EntityReference("systemuser", ownerId));
	osHistory.Attributes.Add("new_assignedto", new EntityReference("systemuser", ownerId));
	osHistory.Attributes.Add("new_orderid", new EntityReference("salesorder", orderId));
	service.Create(osHistory);
}


*This post is locked for comments

I have the same question (0)
  • st738407 Profile Picture
    227 on at

    From the sounds of your description it probably is not this, but just incase.  We had a similar issue in the past and our issue was due to our plugin triggering more than once.  Since I do not see your code looping back to the parent I do not think that is the issue, but in the off chance it is I'd rather provide you with a nonsolution than not say anything.

  • Suggested answer
    saadzag Profile Picture
    1,145 on at

    Hi,

    I think you dont have the same DLL version deployed and the in you visual studio(where you debug).

    Check if you dont have two steps registered.

    Regards,

    Saad

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans