Before you begin
This workflow relies on a user's title (i.e. the Title field in their user record) to determine whether to check for incomplete tasks (i.e. tasks without a completion date). This means that you must first assign titles to your users for this workflow to run properly.
Plans: Enterprise only
Audience: Administrators
When a work order is closed, this workflow checks whether all of its tasks have completion dates, and reopens the work order if any of the tasks are incomplete (i.e. don't have a completion date). Unlike other workflows in this section, this workflow only checks the tasks if the work order is closed by a technician. This means that non-technicians (such as managers) will still be able to close work orders with incomplete tasks.
To learn how to adapt this workflow for a different title (or how to remove that condition entirely), see the Adapting this workflow section at the end of this article.
Configuration overview
Goal
Prevent technicians from closing work orders that have incomplete tasks.
Trigger
Type | What it does |
---|---|
Field was changed from a specific value | Fires whenever a workflow is closed (i.e. its status is changed to the one you select in this trigger) |
Activities
Type | What it does |
---|---|
Run separate activities based on an if/else condition |
Checks the title of the user who closed the work order. If their title does not include "Technician", the condition is met and the workflow does not perform any other activities and the work order stays closed. If their title does include "Technician", the condition is not met and the workflow runs the loop activity in the next row. Note: Although this might seem backwards, the easiest way to understand it is to think of it as the workflow making sure that the user isn't a technician. In other words, if they aren't a technician, it doesn't need to do anything. ("They're not a technician, are they? Oh good, they're not, so I don't need to worry about it.") |
Loop through a list of records and perform common activities against those records |
This sub-activity runs when the above condition is not met (i.e. when the user's title includes "Technician"). It gets the completion date for all tasks in the work order, then runs the condition activity in the next row. |
Run separate activities based on an if/else condition |
This sub-activity checks the completion dates that the loop recorded to see if any are missing (i.e. "null"). If any are missing, the condition is met and the workflow runs the activity in the next row. |
Update a selected field value within a defined object |
This sub-activity runs when the above condition is met (i.e. when one or more of the tasks are missing a completion date). It reopens the work order by changing its status to whichever one you select in the activity. |
Steps
- Go to Settings > Workflows.
- Click New:
- Enter a name for your workflow.
- In the I would like to section, select Run separate activities based on an if/else condition:
- In the Every time that a section, select Field was changed to a specific value:
- Click OK.
- To configure the trigger:
- Click the Trigger tab:
- In the Field drop-down list, select Work Order - Work Order Status id:
- In the Value drop-down list, select the status your organization uses for closed work orders (e.g. Closed, Completed):
- Click OK.
This closes the workflow, which is necessary to apply your trigger settings before moving on to the next step.
- Click the Trigger tab:
- To configure the first condition activity:
- Click the workflow to open it again.
- In the Activities tab, click the activity that was created automatically based on the option you selected in step 4:
- In the Condition field, enter the following code:
rec.findRelatedRecord('intLastModifiedByUserID').strUserTitle not like '%Technician%'
- To configure the sub-activity that loops through the tasks:
- In the Execute these activities when the condition is not true section, click the + button:
- Enter a name for the activity.
- Select the Loop through a list of records and perform common activities against those records option:
- Click OK.
- In the variable name field, enter "wot". This is how we'll reference this activity in the next condition.
- In the Iterable Expression field, enter the following code:
rec.findRelatedRecords('tblWorkOrderTask', 'intWorkOrderID')
- In the Execute these activities when the condition is not true section, click the + button:
- To configure the sub-activity that checks for missing completion dates:
- In the Activities section, click the + button:
- Enter a name for the activity.
- Select the Run separate Activities based on an if/else condition option:
- Click OK.
- In the Condition field, enter the following code:
wot.getColumnValue('dtmDateCompleted') is null
- In the Activities section, click the + button:
- To configure the sub-activity that changes the work order's status:
- In the Execute these activities when the condition is true section, click the + button:
- Enter a name for the activity.
- Select the Update a selected field value within a defined object option:
- Click OK.
- In the Field drop-down list, select Work Order Status id:
- In the Value drop-down list, select the status you want to change the work order to (e.g. Open):
- Click OK.
- In the Execute these activities when the condition is true section, click the + button:
- Click OK on the next 3 screens, until you reach the screen where you can activate the workflow (pictured in the next step). This is because the workflow contains multiple nested activities, so each activity's screen needs to be closed before you can move on to the next step.
- To activate the workflow, switch the status toggle to Active:
- Click OK.
Once your workflow is activated, you may want to test it by closing a work order with incomplete tasks and validating that the workflow ran successfully. To learn more, see Monitor workflow activity.
Adapting this workflow
You can adapt this workflow for a different title by editing '%Technician%' in step 8c. For example, to apply this rule to users with "Contract" in their title instead, you would change the code to:
rec.findRelatedRecord('intLastModifiedByUserID').strUserTitle not like '%Contract%'
If you wanted to remove that condition entirely (which would prevent all users from closing work orders with incomplete tasks, regardless of their title), you would make the following changes:
- In step 4, select Loop through a list of records and perform common activities against those records.
- Skip step 8 entirely.
- Skip steps 9a to 9d. This is because the activity would have already been created automatically in step 4, so you would just open it from the Activities tab instead of having to create it as a sub-activity: