Get Activity Name from Workflow

davide_fais
Tera Expert

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);

....

..

find_real_file.png

6 REPLIES 6

Sanjeev Kumar1
Kilo Sage

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


I've need to get Activity from Workflow which have never been executed


Kalaiarasan Pus
Giga Sage

If I   may ask, why do you need this? What are you trying to do?


report. For each workflow, I need count task number