25 Jul 2017 12:21 AM Have you ever had that moment where you feel like your workflow is set up correctly, but it just isn’t routing quite the way you wanted it to? Understanding the logic behind using Workflow conditions with ‘And’ and ‘Or’ statements can save a ton of time when setting up your approval steps during the implementation of Workflow and help eliminate these moments. Microsoft Dynamics GP uses the same logic and order of operations as SQL. In fact, for those of you who are good with SQL, this makes the conditions even easier to understand and build. Below I have illustrated an example that I hope will help you better understand just how it works. I will use the Purchase Order Requisitions workflow based on a Document Amount and the GP user who Requested the requisition. I have 6 users and their GP User id’s are as follows: LU1, LU2, LU3, LU4, LU5, LU6. Each of my first steps have a different approver and my workflow only requires 1 approval based on the user and dollar amount combination. Let’s focus on the top two approvals for LU1, LU2, and LU3. Here is how I commonly see these conditions set up: (Approval Step for Kelsey) (Approval Step for Cheryl) Using the screenshots above, if LU1 submits a requisition (REQ00000000000001) for $150 who would you expect to be the approver??? We want it to be ‘Cheryl’ according to our chart, but it will actually be both ‘Kelsey’ and ‘Cheryl’ due to our setup. Why? It is due to the order of operations in SQL. Here is the query that we just wrote with our condition. Here is what our requisition looks like in SQL in the POP10200. POPRequisitionNUmber DOCAMNT REQSTDBY REQ00000000000001 150.00 LU1 These are the select statements that we created on our workflow step conditions. Remember, every first step in your workflow is checked at the time you submit, and every first step that is TRUE, will require approval. (In this case we have 4 first steps on the same level and 2 will be true) Notice how the OR statements above no longer include your document amount from your AND condition, they just include the Requested By user ID. This makes both statements true for LU1 regardless of amount. How do we change our conditions so they meet the order of operations in SQL and include our document amount as well for each user combination? We need to have our document amount AND requested by User, included in each OR statement. Please see below for my updated setup. (Approval Step for Kelsey) (Approval Step for Cheryl) Now, using the screenshots above, if LU1 submits a requisition (REQ00000000000001) for $150 who would you expect to be the approver??? We want it to be ‘Cheryl’ according to our chart, and it will be Cheryl only now with the correct setup in place. Here is what our requisition looks like in SQL in the POP10200 again. POPRequisitionNUmber DOCAMNT REQSTDBY REQ00000000000001 150.00 LU1 These are the select statements that we created on our new workflow step conditions. Above you can see that the condition for Kelsey in red is no longer true because our OR statement now also includes the document amount and not just the requested by user id. Cheryl’s step is the only one that is true, now so she will be assigned the approval properly. My hope is that the illustrations above will give someone that light bulb moment if this was unclear beforehand. It is not always easy to convey a concept like this into words a it takes hands on practice to get really good at creating your conditions. In the future, I will add a video to this post as well which may clear things up for those visual learners like myself out there.