Asked by:
CRM 4.0 Plugin causing Workflow Loop Detected Infinite Loop Error

Question
-
Hi there,
I have a plugin that gets triggered on Post Staging on Create and Update based on some rules I try to update the same entity but by doing so I get an error code 0X80040265. The workflow job was cancelled because the workflow started it included in infinite loop. I dont have any workflow. Please help
Monday, May 23, 2011 4:25 PM
All replies
-
I think the error message is confusing in this case, but it sounds like your plugin is causing an infinite loop (by your update in the plugin causing the update to fire again, etc.), and CRM has detected this condition.
You should be able to resolve this by:
- Ensuring that, when you pass an entity to the Update method, you only include the primary key, and the fields that you are modifying
- Either specify filtering attributes in the plugin step registration to only pick up changes to attributes that would cause your update to happen, or write logic in the plugin to check which attributes have changed
Microsoft CRM MVP - http://mscrmuk.blogspot.com http://www.excitation.co.ukMonday, May 23, 2011 7:09 PMModerator -
Here is the method
{
{
ccfRegistrationId =
CTCDEPropHelper.GetKeyValue(this.InputTargetDE, "ccf_registrationid");{
{
ccfRegistrationEntity.ccf_registrationstatus = (
int)RegistrationStatus.Violation; //ViolationccfRegistrationEntity.ccf_violationreason = (
int)RegistrationViolationReasons.MemberDocumentation; // Program DroppedcrmContext.UpdateObject(ccfRegistrationEntity);
crmContext.SaveChanges();
}
{
ccfDocumentedPL = 1;
ccfDocumentedPL = 2;
{
&& o.ccf_registrationyear == registrationYear
&& (o.ccf_numberofchildren == numberOfAllowances || o.ccf_numberofchildren == 0)
&& ((o.ccf_documented == ccfDocumentedPL) || (o.ccf_documented == 3))
&& o.ccf_minimumsalary <= annualSalary
&& o.ccf_maximumsalary >= annualSalary).FirstOrDefault();
{
ccfRegistrationEntity.ccf_projectedcost = paymentAmount * paymentPeriod;
ccfRegistrationEntity.ccf_actualcost = paymentAmount * paymentPeriod;
ccfRegistrationEntity.ccf_weeks = ConvertStringToNullable(voucherEntity.ccf_paymentperiodLabel);
crmContext.UpdateObject(ccfRegistrationEntity);
crmContext.SaveChanges();
}
{
&& o.ccf_registrationyear == registrationYear
&& ((o.ccf_documented == ccfDocumentedPL) || (o.ccf_documented == 3))
&& o.ccf_minimumsalary <= annualSalary
&& o.ccf_maximumsalary >= annualSalary).OrderByDescending(o => o.ccf_numberofchildren).Take(1).FirstOrDefault();
{
ccfRegistrationEntity.ccf_projectedcost = paymentAmount * paymentPeriod;
ccfRegistrationEntity.ccf_actualcost = paymentAmount * paymentPeriod;
ccfRegistrationEntity.ccf_weeks = ConvertStringToNullable(highestChildrenNoVoucherEntity.ccf_paymentperiodLabel);
crmContext.UpdateObject(ccfRegistrationEntity);
crmContext.SaveChanges();
}
}
}
}
}
}
}
Monday, May 23, 2011 8:22 PM