Getting the state of previous task in a workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2014 02:46 PM
Is there a way to get the state of the previous task in a workflow ? Just the previous task, the flow has two tasks on it.
- Labels:
-
Service Mapping

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2014 10:03 PM
Hi Ankit,
You can always accomplish such task by using a glide record.
e.g.
var scTask = new GlideRecord("sc_task");
scTask.get("req_item", current.sys_id);
var scTaskState = scTask.state.getDisplayValue();
However, since you're using a workflow you can use the workflow_scratchpad variables for this. You can set the value of the task in an after update business rule. And access the same from workflow in the next task.
An example of such script could be found at Accessing the Workflow Scratchpad from Business Rules - ServiceNow Wiki
Thanks,
Mandar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2014 12:24 AM
Hi Ankit,
I am guessing that you are referring to workflow activities with 'tasks'. If you want to transfer any value from the previous activity to the current activity, then you can use the workflow scratchpad variables for that. You can declare it like this in the previous activity:-
workflow.scratchpad.variableName = variableValue;
And use it like this in the current activity:-
var myValue = workflow.scratchpad.variableName;
If you need the value of some field in the table on which the workflow is running on, you can retrieve it using current.<field_name>
Thanks & Regards,
Hari