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.

View solution in original post

13 REPLIES 13

Thanks Brent, it worked! I am only new to servicenow and you are right i dont need to use GlideRecord for this. is there a way that i can explore all the possible switches after current.xxxx.xxxx in service now? 

Hi Rex,

If you right click on the header of a change request and select "Show XML" it will bring up a screen with all the technical names of the fields on a change request.

find_real_file.png

XML Form

find_real_file.png

All of these fields are available to you in the current object and are accessible with the following syntax:

current.<fieldname>;

current.<fieldname>.getDisplayValue();

Have a play around and see what you can pull out.

P.S. Remember to mark @Sanjiv Meher answer correct if it helped you. If you found the information I provided useful then please mark the comments as Helpful.

 

Thanks Brent, its good to know

Rex Shi
Giga Contributor

Thank you guys both Sanjiv and Brent