- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2017 10:24 AM
Hi All,
I am fairly new to the ServiceNow Development world. I am also an novice script-er So here is my question/Issue:
I've made an order guide that contains 60+/- check boxes that each would flow to a different approver. On the back end i created a workflow to track role approvals.This is for one of our in house ERP systems. I was able to make the workflow wait for all of the rejections and the approvals but I now have a requirement to note who approved what(which checkbox) in the worknotes of the task. I was able to pull the approvers and their decision (rejected. no longer required, approved) but I am not sure how to get the actual Checkbox that corresponds to the approver.
I used this workflow(Massive I know!!):
This is what is currently created on the worknotes:
Here is the script I used to pull the approvers decision:
var rowCount ;
var sc_approval = new GlideRecord('sysapproval_approver');
sc_approval.addQuery('sysapproval',current.sys_id);
sc_approval.addActiveQuery();
sc_approval.query();
rowCount = sc_approval.getRowCount();
while (sc_approval.next()){
var userid = sc_approval.approver;
sc_user= new GlideRecord('sys_user');
sc_user.addQuery('sys_id',userid);
sc_user.query();
if (sc_user.next()){
var userName = sc_user.name;
}
var theTaskMessage ;
if (theTaskMessage == null){
theTaskMessage = sc_approval.state.getDisplayValue()+' '+userName+ ' \n';
}
else {
theTaskMessage = theTaskMessage + sc_approval.state.getDisplayValue()+' '+userName+ ' \n';
}
}
task.work_notes = theTaskMessage;
So What I need to know is how to pull the variable that was approved form the workflow.
Any help or advise would be greatly appreciated!
Thank you!!
Solved! Go to Solution.
- Labels:
-
Best Practices
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2017 07:58 AM
so on the same script change this line to
theTaskMessage = sc_approval.state.getDisplayValue()+' '+userName+ ' \n';
theTaskMessage = sc_approval.state.getDisplayValue()+' '+userName+ ' ' + sc_approval.wf_activity.getDisplayValue() + ' \n';
and that should print the workflow activity name on the same line.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2017 10:33 AM
Hi Keisha
Apologies but I'm a bit lost. Do you mind to explain me which kind of info you need and where.
Cheers
R0b0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2017 11:20 AM
Hi!
I am trying to get the approved variable name and the approver who approved it.
Ex. Check box A was approved by John Doe and checkbox B was Rejected by Mickey Mouse etc...
I hope that makes sense!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2017 11:25 AM
i understand completely what you are asking.. there is no EASY way to do that.. however what you can do is rename your workflow activities for the approval to be approval for <checkbox name>
now you have two options... 1 > in the script you use to find the approval you can pull the wf activity display name.. and put the status of the approval just cycle through them all and write to the record...<if you don't want to change the wf activity name you can always use a case structure and look up the wf activity <preferably by sid> and put in the variable name from there.
2> create a workflow variable for each check box ... approval for ... now in the approved and rejected workflow paths update that variable with either approved or denied and the approver... then after all approvals update the task with the variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2017 05:54 PM
I am thinking about taking the changing of the WF activity name route. Am I going in the right direction?
var WF = new GlideRecord ('wf_activity');
WF.addActiveQuery();
WF.addQuery('name',current.sys_id);
//Test
gs.addInfoMessage(WF.name.getDisplayValue() );