fetch the current workflow for a change request

Rex Shi
Giga Contributor

Hi there,

I am trying to write a simple script within the workflow to fetch the current change id within the normal change workflow, i found out its not really working.

var gr = new GlideRecord("change_request");
gr.addQuery('number',current.sys_id);
gr.query();

i think the gr.addQuery('number',current.sys_id) is not working, but i cant find the right value to fetch , has anyone done this before ? 

 

thanks 

1 ACCEPTED SOLUTION

You don't need to query the change record for that. Because you have all the attributes in the current object already. current.number will give you Change ID. current.sys_id will give you sysid of the change request

 

You can use current.assignment_group to get the sys id of the assignment group.

And current.assignment_group.getDisplayValue to get the display value of the assignment group.


Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

13 REPLIES 13

SanjivMeher
Kilo Patron
Kilo Patron

You can use current.number, which will return you the change number.


Please mark this response as correct or helpful if it assisted you with your question.

Hi Sanjiv,

 

Thanks for replying, i tried with gr.addQuery('number',current.number);

but i dont think that worked. I am trying to get this workflow to look up the assignemnt group in change table, if its the right assignment then it will add that group to the change approvers list.

You don't need to query the change record for that. Because you have all the attributes in the current object already. current.number will give you Change ID. current.sys_id will give you sysid of the change request

 

You can use current.assignment_group to get the sys id of the assignment group.

And current.assignment_group.getDisplayValue to get the display value of the assignment group.


Please mark this response as correct or helpful if it assisted you with your question.

Thanks Sanjiv,

 

it worked! iam new to servicenow and looks like i dont need a GlideRecord for this. by the way is there a way that I can explore all the possible variable that i can use after current.xxxxx.xxxxx.