Get Activity Name from Workflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2017 04:14 AM
Hi ServiceNow Team,
I'd would get Activity Name from Workflow:
I've a workflow on sc_req_item table, and I'd get by script only names of activity Catalog Task:
This screenshot is my Workflow called "Workflow_test". For this workflow, I'd extract all Activity name of "catalog task":
workflow name: "Workflow_Test"
workflow tasks name: "Task Test 1", "Task Test 2", "Task Test 3"
An possibile query could start:
var wf = new GlideRecord('wf_workflow');
wf.get.(sys_id);
....
..
- Labels:
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2017 04:56 AM
Hi Davide,
You can get Active Activity with the help of following script.
var grWFContext = new GlideRecord('wf_context');
grWFContext.addQuery('id', current.sys_id); // sc_req_item sys_id
grWFContext.query();
if (grWFContext.next()){
var grWFExec = new GlideRecord('wf_executing');
grWFExec.addQuery('context', grWFContext.sys_id);
grWFExec.query();
if (grWFExec.next()){
var activity = grWFExec.activity.name;
gs.print(activity);
}
}
Try it

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2017 06:12 AM
I've need to get Activity from Workflow which have never been executed

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2017 06:17 AM
If I may ask, why do you need this? What are you trying to do?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2017 06:57 AM
report. For each workflow, I need count task number