Best way to handle multiple IF type conditions in a workflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2019 04:24 PM
I have a question on the best way to handle multiple IF type statements in a workflow design. It seems like I can accomplish what I need with several IF conditions connected together, but with the number of possibilities I need to account for that seems a bit messy.
Basically what I want to do is check if certain fields on a form are set to specific values and then set a value. As an example:
If Company = A and Department = X then move to Set Value in the Approver field to a specific person. The issue is of course that Company A has many departments and the number of IF conditions would get pretty unwieldy. Example:
I think that the Switch condition is supposed to handle this type of situation, but I'm just not seeing the best way to properly configure that for this type of situation where Company A has 10 different departments, Company B the approver is always the same, Company C has 5 departments etc.
Any suggestions on the best way to handle this type of situation?
- Labels:
-
Best Practices
-
Workflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2019 04:39 PM
Hi Marcel,
How about using a custom table that maps department to the approver. Use this table then to set your approvers.
Regards,
Raf

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2019 05:42 PM
I've thought about this a bit, and previously was doing this off of fields in the Cost Center table to determine who the approver is, but with the way the data is structured that doesn't work well any more in this case. Since our Finance department moved to a unified chart of accounts across several companies a single department code could apply to any one of 4 companies, all with a different potential approver.
I could likely create a new table that uses the Company and Department to define the approver as well, just need to figure out the best way to then grab that information and set it on the request form during submission. I'm definitely going to look into this as an option.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2019 07:25 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2019 08:27 PM
I'm having a bit of trouble with this, and I'm sure it's just my lack of experience with using workflows in this way is why. I've got a script working to create the approvals like I want based off of information on the form and another data table. What I'm having some problem with though is just setting the value of a field on the form that shows the name of the approver. I've got the code below in my workflow Approval - User activity:
var answer = [];
var gr = new GlideRecord('u_variance_approvers');
gr.addQuery('u_entity', current.u_entity_code);
gr.addQuery('u_department', current.u_department_code);
gr.query();
while(gr.next())
answer.push(gr.u_approver);
current.u_department_approver=gr.u_approver;
I'm sure I'm missing something obvious, but how do I take the answer from the gr query and use that to also populate the field on my form u_department_approver?