Create Change Request through servicenow script

Bala19
Tera Contributor

Hello All,

I have a catalog form. On the submission of this catalog form I have create a normal change request and assign values to it through script. Could you please someone guide me?

Thanks

Bala

 

 

1 ACCEPTED SOLUTION

Hi Bala,

Sample script here

var gr = new GlideRecord('change_request');

gr.field1 = current.variables.<variableName1>;

gr.field2 = current.variables.<variableName2>;

... and so on

gr.insert();

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Bala,

you can have either of these 2 approaches; are you taking values from catalog item and populating in change request

1) have workflow for this RITM; in that use run script activity and create change request by fetching values from variables using current.variables.<variableName>

2) have after insert business rule on sc_req_item table with condition as catalog item is yours and have script similar to workflow run script

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Bala19
Tera Contributor

Thanks Ankur. I have all the catalog values and derived few more values needed for CR in my run script. But I am not sure how to create the CR from there on.

thanks

Bala

 

Hi Bala,

Sample script here

var gr = new GlideRecord('change_request');

gr.field1 = current.variables.<variableName1>;

gr.field2 = current.variables.<variableName2>;

... and so on

gr.insert();

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

hi ankur,

Can you tell me the possible ways to create a change request

 

Thanks,

Shreshta