Stop workflow running multiple times RRS feed

  • Question

  • I have a simple workflow running on Incidents and starts when record status changes. This workflow sends an email to the owner if someone else has closed / completed the incident other than the owner.

    I also have a plugin on incident, when the incident is updated or completed the plugin needs to update a calculated field so sometimes I need to reopen the incident. This will cause my workflow to run 2-3 times sending 2-3 emails.

    I´ve tried creating a custom workflow running on top of the workflow trying several ways with depth / SharedVariables but it seems to me that the workflow is running on independently (each instance).

    My next step was to query the incident and check if the workflow has been ran and then avoid running the workflow. Maybe it doesn´t make any sense but I could give it a try.

    Are there any suggestions here?


    Thursday, November 6, 2014 3:22 PM

All replies

  • you can query the incident to check if the workflow has been ran, but will not work if the workflow has been set to delete the history when completed or you clean the history after.

    An alternative is to create a boolean field and set to true when you run your workflow the first time. in your workflow you check if this field is false before sending the email.

    My blog: www.crmanswers.net - Rockstar 365 Profile

    Thursday, November 6, 2014 3:54 PM
  • Hi Guido, thanks for your post.

    My solution was this:
    1. Created a Timestamp field on incident
    2. Created a Plugin that checks if the Timestamp field is empty or if the current timestamp is not > Current time - 15 minutes
    This prevents the plugin running within the same 15minutes, because I want to allow reopen the incident and closing it again when the 15 min period is passed
    The 15 min time limit is configure-able in unsecured config.
    3. Create an email record
    4. Exectue a send email request
    5. The plugin is set on the Pre-Operation stage

    All tests are green :-)


    Thursday, November 13, 2014 9:00 AM
  • Hi Ragnar,

    The calculated field can be updated via Target entity in the Pre-Operation rather than calling Update method. This way you do not need to re-open the incident.


    Friday, November 14, 2014 12:43 AM