Using a UI Action to create a Change Request from Standard Change Templates

KeithM2
Kilo Contributor

I have a standard change template specifically for adding/removing storage space on a server.  I want to create a UI action that would create a standard change using that specific template.  Right now, the way the UI action I have created is setup, it will take me to the interceptor page for the standard change templates and I have to drill down to get to that standard change template.  By the time the change is created, I've lost the reference to the incident it is created from.  Any thoughts/ideas on how to setup the UI action to create the standard change using that specific standard change template and still keep the reference to the originating incident?  Here's the script I've got for the UI action:

 

(function(current, previous, gs, action) {


var changeRequest = ChangeRequest.newStandard();

var url='com.glideapp.servicecatalog_category_view.do?v=1&sysparm_parent=b0fdfb01932002009ca87a75e57ffbe9';
action.setRedirectURL(url);

action.setReturnURL(current);


})(current, previous, gs, action);

 

I appreciate everyone's input!

4 REPLIES 4

sachin_namjoshi
Kilo Patron
Kilo Patron

YOu need to use scripted templates in your UI action code.

Please check below for all scripted templates examples

 

https://docs.servicenow.com/bundle/jakarta-platform-administration/page/administer/form-administration/reference/r_ScriptedTemplates.html

 

Regards,

Sachin

SanjivMeher
Kilo Patron
Kilo Patron

 

You can get the link address by copy link

 

 

 

Then edit that link and use it. 

Another option is do a GlideRecord and Create the Change Request using the UI action.

 

var chg = new GlideRecord('change_request');
chg.initialize();
chg.short_description = current.short_description;

chg.type='standard';

chg.std_change_producer_version = '<sysid of the template version>';

var chg_id = chg.insert();

action.setRedirectURL(chg);

current.change_request = chg_id;

current.update();


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

KeithM2
Kilo Contributor

I appreciate the suggestions but I keep getting directed to the Standard Change Template Library

just want to add here , in standard change request it has multiple interceptor defined , make sure which one would like to open through the ui action. i tested with one of them and it worked

try now.

 

var url ="/change_request.do?sys_id=-1&sysparm_query=type%3dstandard^std_change_producer_version%3da08e02ec47410200e90d87e8dee4905a&sysparm_link_parent=abbcbbbf47700200e90d87e8dee49041&sysparm_catalog=e0d08b13c3330100c8b837659bba8fb4&sysparm_catalog_view=catalog_default";

url += current.sys_id;

action.setRedirectURL(url);