January 17, 2018, 4:43 pm - James Farrer
Here's a script that goes through the workflow activity fields and prints out where the group is listed in workflows.
// Sys ID of the group that we're testing for
var group_id = "c4762f920fd0310066e76ab8b1050e58";
var group_gr = new GlideRecord("sys_user_group");
if (group_gr.get(group_id)) {
gs.print("Querying workflows for group: " + group_gr.getDisplayValue());
}
var wf_var_value_gr = new GlideRecord("sys_variable_value");
wf_var_value_gr.addQuery("value", group_id);
wf_var_value_gr.query();
while (wf_var_value_gr.next()) {
// Query for the workflow activity
var wf_activity_gr = new GlideRecord(wf_var_value_gr.document);
if(wf_activity_gr.get(wf_var_value_gr.document_key)) {
if(wf_activity_gr.workflow_version){
// Query for the workflow version
var wf_version_gr = new GlideRecord("wf_workflow_version");
wf_version_gr.addQuery("sys_id", wf_activity_gr.workflow_version);
wf_version_gr.addQuery("published", true);
wf_version_gr.query();
if (wf_version_gr.next(wf_activity_gr.workflow_version)) {
gs.print("Group is assigned to " + wf_version_gr.name + " -> " + wf_activity_gr.name);
} else {
//gs.print("WF version not published " + wf_activity_gr.workflow_version.getDisplayValue() + " -> " + wf_activity_gr.name);
}
} else {
gs.print("Workflow activity version is blank for " + wf_activity_gr.name);
}
}
}
