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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Workflow error: This workflow job was canceled because the workflow that started it included an infinite loop. Correct the workflow logic and try again....

(0) ShareShare
ReportReport
Posted on by

Hi,

When workflow started I get a error:

'This workflow job was canceled because the workflow that started it included an infinite loop. Correct the workflow logic and try again. For information about workflow logic, see Help.'

Part of code:

AssociateRequest areq = new AssociateRequest();
areq.Target = new EntityReference("a24_assessment_questions", new Guid(question.Id.ToString()));
areq.RelatedEntities = new EntityReferenceCollection();
areq.RelatedEntities.Add(new EntityReference("systemuser", new Guid(evaluator.Id.ToString())));
areq.Relationship = new Relationship("a24_assessment_questions_systemuser");
organizationService.Execute(areq);

If someone knows have to solve this , please help me..

Thanks in advance..

*This post is locked for comments

I have the same question (0)
  • Rahat_Gaba Profile Picture
    10 on at
    RE: Workflow error: This workflow job was canceled because the workflow that started it included an infinite loop. Correct the workflow logic and try again....

    ive included context.depth but my issue is not resolved

  • Community Member Profile Picture
    on at
    RE: Workflow error: This workflow job was canceled because the workflow that started it included an infinite loop. Correct the workflow logic and try again....

    Thank you very much.

    Kind regards

    Martin

  • Verified answer
    BadrinathB Profile Picture
    970 on at
    RE: Workflow error: This workflow job was canceled because the workflow that started it included an infinite loop. Correct the workflow logic and try again....

    All is well as long as your business needs are fulfilled :). It is Ok to use context.Depth to avoid infinite loop.

    Every time a running plug-in or Workflow issues a message request to the Web services that triggers another plug-in or Workflow to execute, the Depth property of the execution context is increased. If the depth property increments to its maximum value within the configured time limit, the platform considers this behaviour an infinite loop and further plug-in or Workflow execution is aborted.

    The maximum depth (8) and time limit (one hour) are configurable by the Microsoft Dynamics 365 administrator using the PowerShell command Set-CrmSetting. The setting is WorkflowSettings.MaxDepth.

  • Community Member Profile Picture
    on at
    RE: Workflow error: This workflow job was canceled because the workflow that started it included an infinite loop. Correct the workflow logic and try again....

    Hi,

    In plugin I have :

    base.RegisteredEvents.Add(new PluginEvent()
    {
    Stage = eStage.PreOperation,
    MessageName = MessageNames.Associate,
    PluginAction = ExecutePluginLogicConcatUserAssociate
    });

    When I put this part of code in plugin step:

    if (context.Depth > 1)
    { return; }

     

    Everything works well. I don't know it is good idea with this part of code ? 

  • Chadi Tannous Profile Picture
    1,039 on at
    RE: Workflow error: This workflow job was canceled because the workflow that started it included an infinite loop. Correct the workflow logic and try again....

    do you need it for this association or a different one ?

  • Community Member Profile Picture
    on at
    RE: Workflow error: This workflow job was canceled because the workflow that started it included an infinite loop. Correct the workflow logic and try again....

    Hi,

    I have found one plugin:

    6131.process.jpg

    When I disabled step everything works well.

    But I need that step...

    Can someone give a advice how can I run both without issue ?

    Thanks in advance..

  • Community Member Profile Picture
    on at
    RE: Workflow error: This workflow job was canceled because the workflow that started it included an infinite loop. Correct the workflow logic and try again....

    Hi,

    I will check it....

    Thanks

  • Chadi Tannous Profile Picture
    1,039 on at
    RE: Workflow error: This workflow job was canceled because the workflow that started it included an infinite loop. Correct the workflow logic and try again....

    any plugin on Association running in the background

  • Community Member Profile Picture
    on at
    RE: Workflow error: This workflow job was canceled because the workflow that started it included an infinite loop. Correct the workflow logic and try again....

    Hi,

    Code:

    public class AssignEvaluatorToAssessmentQuestionActivity : CodeActivity
    {
    [Input("EvaluatorReference input")]
    [ReferenceTarget(SystemuserEntity.EntityName)]
    public InArgument<EntityReference> EvaluatorReference { get; set; }

    [Input("EvaluatorReference assessment question")]
    [ReferenceTarget(AssessmentQuestionEntity.EntityName)]
    public InArgument<EntityReference> AssessmentQuestion { get; set; }

    protected override void Execute(CodeActivityContext context)
    {
    ITracingService tracingService = context.GetExtension<ITracingService>();
    IOrganizationService organizationService = CrmHelper.CreateOrganizationService(context);

    EntityReference question = this.AssessmentQuestion.Get(context);
    EntityReference evaluator = this.EvaluatorReference.Get(context);

    tracingService.Trace(string.Format(CultureInfo.InvariantCulture, "Received ref. for evaluator with id {0}", evaluator.Id));

    try
    {
    AssociateRequest request = new AssociateRequest();
    EntityReference mon1 = new EntityReference("a24_assessment_questions", new Guid(question.Id.ToString()));
    EntityReference mon2 = new EntityReference("systemuser", new Guid(evaluator.Id.ToString()));
    request.Target = mon1;
    request.RelatedEntities = new EntityReferenceCollection { mon2 };
    request.Relationship = new Relationship("a24_assessment_questions_systemuser");
    organizationService.Execute(request);
    }
    catch (Exception ex)
    {
    tracingService.Trace(ex.ToString());
    throw;
    }
    }
    }

     

     

    Process:

     

    1346.process.jpg

    Thanks in advance..

  • Verified answer
    David Jennaway Profile Picture
    14,065 on at
    RE: Workflow error: This workflow job was canceled because the workflow that started it included an infinite loop. Correct the workflow logic and try again....

    What is the rest of the code, and what are the workflow steps, and triggers ? If this AssociateRequest would cause the workflow to fire again (for example, if you had a plugin on the Associate message that updated one of the related entities, and that update triggered the workflow), then the infinite loop detection is doing its job

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#3
MA-04060624-0 Profile Picture

MA-04060624-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans