Did You Know:
Through an ATC workflow script, you can have document statuses change to Approved by any user, even those who do not have permission to approve the Doc type. This workflow can make it easier for approval of certain documents that meet a criteria without having to give users permission to approve all documents of that Doc type.
Questions to Consider:
- Should the document get approved without having the user manually change the document status?
- Should the document get approved because it reaches a certain point in the route?
If the answers are yes, the following instructions indicate how to set that up.
Predefined Route:
The first step is to establish a predefined route. Include in your route a “threshold,” such as sequence 100 or 500. The first person after this threshold to route the document forward will cause the document to be approved because of a workflow script.
If any user before the threshold does not want the document to be approved they can “send back” or “restart” the route with their reasons recorded in their route response.
Workflow Scripts:
Since the document status change can fail, you want a script that allows the document to display a validation message to the user and prevents the document from moving forward in its route.
Since your user may not have approval permission, you want a script that saves the status change with full permissions.
The above is accomplished using two workflow scripts.
Route Forward Workflow:
- Add a new row to your Workflow Script Library with a descriptive name such as CCORouteForward.
- Save.
- Find that row, expand it and map the script to your document type.
- Specify Route Forward as the “trigger when”. This means that if the workflow fails it will block the route forward allowing the user to make corrections. Note that Route Forward workflows are run every time the route sequence is about to change, so your script needs to deal with “when” the approval should happen.
- Save
ATC: EXIT NOT PASTSEQ 99
|
As discussed, reaching SEQ 100 is the signal that the CCO is ready to approve, so we exit if it is earlier than sequence 100. |
ATC: EXIT WHEN STATUS = A
|
…but also EXIT if already approved |
ATC: CATCH SHOW The document should be PENDING before now. It is [DocHeader_Status] ATC: ERRORIF WHEN NOT STATUS = P
|
Display a message and block things if the document is not pending |
ATC: IF DocRevision.CostImpact > 90000000 ATC: * QUERY qCCODoubleChecker ATC: * CATCH SHOW Cost Impact [FC2_DocRevision_CostImpact] requires additional review ATC: * ERRORIF WHEN qCCODoubleChecker.Block = 1 ATC: ENDIF
|
This block is OPTIONAL and included to illustrate how we might “double check” that the correct route was used and other requirements met…
We would write and run a SQL query that would return a row with Block=1 or Block =0 See below for more tips! |
ATC: INVOKE CCOInvokedStatus |
Invokes a script with full system access (see below) |
Invoked Approval Workflow:
This script is very simple. It must have the name included in your ATC: INVOKE command. The important part is that the script was run with ATC: INVOKE (instead of ATC: CALL) so that the commands run with system level permissions.
ATC: SET STATUS = A |
Changes the document status – this always works |
ATC: CATCH SHOW {2}{1}<br>Trying to APPROVE by [DocMasterDetail_EditUser] |
Establishes the error message. The “by [DocMasterDetail_EditUser] will display “by Spitfire” when the script is run with ATC: INVOKE |
ATC: SAVE WITH FATAL |
Attempts the save, performs all validations. If the save throws an exception, it is caught and displayed and the Route Forward is blocked |
Other Checks
As mentioned above, the crucial part is having appropriate logic in your Route Forward workflow to decide when to Invoke the status change.
End of Route
KBA-01876; Last updated: July 22, 2025 at 12:25 pm