The CreatorCon Call for Content is officially open! Get started here.

Apply Standard Template for Change Request through Script

Nirmala5
Mega Contributor

Hi All,

I'm trying to create Standard Change Request through Pre-Approved Template. I'm using below script in workflow to create one, but its creating "Normal" Change request all other fields like Implement Plan, Justifications, Assignment Group, etc. are copied with same content mentioned in template. Only difference is Type of the change its inserted as "Normal"

var gr=new GlideRecord('change_request');
gr.Initialize();
gr.applyTemplate('standard_rfc');
gr.type='standard';
gr.insert();  

//This is creating Normal Change

Kindly help to find the script through which I can submit a standard change through script.

5 REPLIES 5

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

Try this, add appropriate values for placeholders for sys_id and name

var chg = new GlideRecord('change_request');
chg.initialize();
chg.type = 'standard';
chg.std_change_producer_version = 'sys_id'; // Sys ID of the Standard Change Templates version
chg.applyTemplate('template_name');
chg.insert();

-Anurag

-Anurag

Hi Anurag,

 

Thank you,

I have tried the script which you have mentioned, tried in Scripts-Background.

Yes CR got created but type still remains as "Normal". 

find_real_file.png

@Nirmala5 ,

 

I am facing the same problem. Did you get the solution for this?
A normal change is getting created. Though I am using a standard template and set the type to standard.

 

Thanks,

Bharath

amani mogili
Tera Contributor

Did anyone find the solution for this one?