Customer Engagement & Dynamics CRM Forum

Expand all | Collapse all

Stop Workflow Step question

  • 1.  Stop Workflow Step question

    TOP CONTRIBUTOR
    Posted Apr 25, 2019 02:58 PM
    Edited by Nelson Johnson Apr 25, 2019 03:01 PM

    I have a question about the use of 'Stop Workflow' with status of Success. Can anyone explain (with evidence) why it should be used at the end of a workflow? I cannot find any blog posts, or documentation that explains why so many people are being told to put it at the end of every workflow. So far, everyone I have asked just shrugs and says "I was told to do that" and I feel it is not a best practice.

    I can (sort of) understand using it in the middle of a workflow, for example if the person is not a programmer and cannot understand IF logic more than 1 level deep and therefore they are taught to use it to prevent unexpected things to happen. But I cannot understand why people are being trained to put it at the end of every workflow.



    ------------------------------
    Thanks.
    Nelson Johnson, Solution Architect
    BroadPoint, Inc., Bethesda MD
    Link with me! https://www.linkedin.com/in/nelsonjohnson/
    ------------------------------
    Academy - Online Interactive Learning from Experts


  • 2.  RE: Stop Workflow Step question

    TOP CONTRIBUTOR
    Posted Apr 25, 2019 03:06 PM
    Nelson,

    Who said it should be used? I work with workflows since 4.0 and sometimes I see those steps in workflows designed by others. Usually I just drop those steps because there is no sense in it.

    ------------------------------
    Andrew Butenko
    ------------------------------

    Academy - Online Interactive Learning from Experts


  • 3.  RE: Stop Workflow Step question

    SILVER CONTRIBUTOR
    Posted Apr 26, 2019 03:33 AM
    I agree with not just using it at the end of a workflow - UNLESS you want to force the workflow to save itself in a log. otherwise the log gets automatically deleted.

    ------------------------------
    Paul Smith
    SSAFA
    London
    ------------------------------

    Academy - Online Interactive Learning from Experts


  • 4.  RE: Stop Workflow Step question

    TOP CONTRIBUTOR
    Posted Apr 26, 2019 05:46 AM
    Yeah, I see that in workflows too and never understood it. If I see it, I usually delete that step. :)

    ------------------------------
    Chris Harrington
    Solutions Architect
    PowerObjects, an HCL Company
    ------------------------------

    Academy - Online Interactive Learning from Experts


  • 5.  RE: Stop Workflow Step question

    TOP CONTRIBUTOR
    Posted Apr 26, 2019 07:22 AM
    Edited by Rex Kenley Tan Apr 26, 2019 07:24 AM
    Nelson

    It is basically a "return" value.

    Always try to cleanly end workflows. Use Stop Workflow steps wherever possible to ensure all workflow logic exits cleanly and no system resources are consumed unnecessarily. Stopping a workflow with Cancel or Success can help evaluate the status of workflows after they run.

    https://crmbook.powerobjects.com/system-administration/processes/managing-processesbest-practices/

    Stop Workflow step makes Dynamics 365 behave differently on real-time workflow compared to background workflow.  While the workflow design is exactly the same in both scenarios, real-time workflows rolls back the transaction, if workflow is stopped with status Canceled.  This is due to the fact that real-time workflows behaves same as a post-operation plugin which if failed rolls back the complete transaction.

    Since the background workflow runs outside of the main transaction, it executes each step independently and when workflow is stopped with Canceled status, complete transaction is not rolled back.

    http://dyn365apps.com/2017/03/29/kb-dynamics-365-workflow-step-stop-workflow-succeeded-vs-canceled-cancelled/

    **Although, I am a bit concerned about what the author said of background workflows NOT rolling back when Cancelled.

    ------------------------------
    Rex Kenley Tan, MCP
    Tallmadge OH
    https://www.youracclaim.com/users/rex-kenley-tan

    *Always be CURRENT with JavaScript & C#, NEVER be obsolete.

    DISCLAIMER: All views expressed on this site are my own and DO NOT represent the opinions of ANY entity whatsoever with which I have been, am now, or will be affiliated.
    ------------------------------

    Academy - Online Interactive Learning from Experts


  • 6.  RE: Stop Workflow Step question

    TOP CONTRIBUTOR
    Posted Apr 26, 2019 09:40 AM
    Great response Rex. I completely understand the use of Stop Workflow with Cancelled status in those scenarios. My issue is really around the fact that people are being taught to use Stop Workflow with Success at the end of their workflows. I have been using CRM since v3, and here is my problem with the advice provided in the blog you cited - there is absolutely no evidence that adding the Stop Workflow with Success at the end of a workflow provides any benefit.

    I am the kind of personality that questions why people do things and I am not a fan of blind dogma. I believe that this advice is being passed out because there are non-programmers among us that cannot deal with IF conditions more than 1 deep and it is easier to tell them to just put it everywhere instead of trying to give them rules.

    ------------------------------
    If this answered your question, please click on the arrow button next to Reply Inline and choose 'Make Best Answer.'
    Thanks.
    Nelson Johnson, Solution Architect
    BroadPoint, Inc., Bethesda MD
    Link with me! https://www.linkedin.com/in/nelsonjohnson/
    ------------------------------

    Academy - Online Interactive Learning from Experts


  • 7.  RE: Stop Workflow Step question

    TOP CONTRIBUTOR
    Posted Apr 26, 2019 10:22 AM
    Edited by Rex Kenley Tan Apr 26, 2019 10:27 AM

    Nelson

    Yes, there seems to be no benefit to mark workflows with Succeed(especially with self destruct workflows).

    But in situations where keeping a workflow log for audits is required, it may be needed. One could argue that a successful run status is enough to indicate that it succeeded, but how do you know for sure? What if one of those steps just decided to quit for some unknown reason?

    Ex:
    If (GoToFunctionThatReturnsTrue(SomeParameter))
    else
    Canceled

    Now one can "assume" (and we know what that word stands for :) ) that if it doesn't return cancel then it succeeded, but we all know that is not true.

    If (GoToFunctionThatReturnsTrue(SomeParameter))
    Succeeded
    else
    Canceled

    In this case we KNOW for sure that the function worked and returned a true value because Succeeded was returned.

    So basically you are sacrificing certainty if you don't return a Succeeded value. This can be VERY PAINFUL during audits.

    It's the same argument in the SQL realm, is a null bit field false? We know common sense would say, well if it's not checked then it's false. But SQL developers know that is not the case. 

    https://softwareengineering.stackexchange.com/questions/133600/should-i-store-false-as-null-in-a-boolean-database-field



    ------------------------------
    Rex Kenley Tan, MCP
    Tallmadge OH
    https://www.youracclaim.com/users/rex-kenley-tan

    *Always be CURRENT with JavaScript & C#, NEVER be obsolete.

    DISCLAIMER: All views expressed on this site are my own and DO NOT represent the opinions of ANY entity whatsoever with which I have been, am now, or will be affiliated.
    ------------------------------

    Academy - Online Interactive Learning from Experts


  • 8.  RE: Stop Workflow Step question

    MICROSOFT MVP
    Posted Apr 29, 2019 02:06 AM
    Hi Nelson,

    Sidetracking slightly, but I would like to point out that the "non-devs putting Stop steps everywhere" approach definitely has its advantages.
    One obvious reason is that introducing or removing an if-clause may require you to recreate all parts of the workflow affected by the if-clause (moving all subsequent steps inside the if or out from it). Using negaive ifs where you exit instead has a great advantage here.

    From another point I definitely like the guard clause approach better than nesting if-clauses. See my reasoning here :) https://jonasrapp.net/2019/03/flow-guards/

    Regarding stop steps at the end of workflows, I am just as confused as you ;)


    ------------------------------
    Jonas Rapp
    MVP, Enterprise Architect
    Sweden
    ------------------------------

    Academy - Online Interactive Learning from Experts


  • 9.  RE: Stop Workflow Step question

    D365UG/CRMUG ALL STAR
    Posted Apr 30, 2019 10:22 AM
    I am one of the guilty parties putting Stop Workflow steps at the end of workflows!

    I use them within workflows for the If logic like you mentioned. This is useful if there is multiple branches to end each branch with a Stop Workflow. This makes it a bit easier to read and ensure that you (or someone who edits your workflow later) won't accidentally have steps that occur for the wrong branches/logic. Also helpful if you are editing a complex workflow (possibly authored/architect-ed by someone else) where you need to add a case that doesn't trigger the rest of the logic for example.

    But I also include a Stop Workflow as my last step in most workflows. I feel it just makes it easier to understand and cleaner. I guess my logic is "Why not?" instead of "Why?".

    ------------------------------
    Kylie Kiser
    Program Manager, CRM Experience
    Centreville VA

    www.CRMUG.com/Washington
    ------------------------------

    Academy - Online Interactive Learning from Experts


  • 10.  RE: Stop Workflow Step question

    SILVER CONTRIBUTOR
    Posted Apr 30, 2019 10:50 AM
    I wasn't aware that people did this. I've never done it myself. But I guess it does no harm, as it essentially does nothing :)

    ------------------------------
    Ben Bartle
    IBM
    ------------------------------

    Academy - Online Interactive Learning from Experts


  • 11.  RE: Stop Workflow Step question

    TOP CONTRIBUTOR
    Posted May 01, 2019 11:08 AM
    We've used Stop Workflow but not with the status of Success.  We use the status of Canceled to stop cases from being resolved if certain fields haven't been populated.  We've also used this approach on the Account entity because we submit account requests from Dynamics to our ERP.  The workflow will stop account requests from being submitted if certain account and Primary Contact fields haven't been populated.  In each scenario, the workflow will show a warning message to the user and ask them to populate the required fields.

    ------------------------------
    Mark Aston
    Data Analyst
    Ordnance Survey
    Southampton, UK
    ------------------------------

    Academy - Online Interactive Learning from Experts


  • 12.  RE: Stop Workflow Step question

    Posted May 06, 2019 09:14 AM
    I asked this question a long time ago to one of our vendors as to why someone was using the Stop Workflow at the end of the statement and granted it doesn't serve much of a purpose at the end, it doesn't help with readability, especially for those that may not understand the IF logic as you mentioned.

    Hope that helps,
    Chrys

    ------------------------------
    Chrys Wilkinson
    CRM Analyst
    VA
    ------------------------------

    Academy - Online Interactive Learning from Experts


If you've found this thread useful, dive deeper into User Group community content by role