
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2019 06:51 AM
Hello,
This is probably a stupid question, but I can't seem to find an answer in the documentation or in the community forums.
How can I access the approvers from a workflow approval step in a run script step later on in that same workflow?
Looking at the image below, I have a simple workflow in a London (p4) developer instance with an approval step, some timer thing, and a run script.
If the approval step results in an approve, I want the run script to make an API call containing the name(s) of the approver(s) and the item that was approved. For this particular post, I am more interested in getting the names of the approvers. I currently have a script attached to the approval step that sets the approver name to a workflow.scartchpad variable, but it is hard-coded as you can see below.
gs.info('Inside of Test Approval');
workflow.scratchpad.jordi = 'admin'; // TODO: get approver dynamically
gs.info('Workflow Scratchpad Jordi: ' + workflow.scratchpad.jordi);
gs.info('Inside of Run Script');
gs.info('The transient workflow scratchpad jordi variable: ' + workflow.scratchpad.jordi);
gs.info('Making API Call...');
try {
var r = new sn_ws.RESTMessageV2...
} catch(ex) {
var message = ex.message;
}
gs.info('Processing Response...');
...
How can I dynamically set this scratchpad variable? Maybe something like workflow.scratchpad.jordi = workflow.getVariable('approvers');?
Please let me know if you have any ideas or resources.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2019 09:29 AM
In the approver user activity, use generate the approval via script and there itself initialize the scratchpad variable
eg answer = [];
var gr = new GlideRecord("sys_user");
gr.addQuery("user_name", "able.tuter");
gr.query();
while (gr.next()) {
answer.push(gr.getValue("sys_id"));
}
workflow.scratchpad.approvers = answer;
Note: Please mark reply as correct / closed if it has answered your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2019 11:40 AM
If the table that workflow is running on is not a task extended, please use

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2019 01:00 PM
This workflow is based on the sys_audit_role table.
I tried the
gs.info(rec.get('sysapproval', current.document_id));
but it also printed false.
I think I'll just go with the "Set the approver within the approval script" suggestion.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2019 06:25 PM
if the approver value is coming from the table that the workflow is on, then you can use
current.APPROVER_FIELD_NAME.getDisplayValue()

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2019 11:13 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2019 12:05 AM
You might be able to do the same on "Approvals" as I do on some "Catalog Tasks".
I have no idea if this will work, and no time to test it right now;
The problem I ran into is that I want to get some information from the tasks later in the process, but there's no built-in way to get any identifier for the new tasks (that I could find at least), so I do it by script.
In the script-section for the Catalog Task, I do something like this:
workflow.scratchpad.my_taskid = task.setNewGuid();
I can then access "workflow.scratchpad.my_taskid" later in the workflow to then access any information on that specific catalog task (via GlideRecord for example).