On invoking Standard Change Template through run script, CR created is not getting set as "Standard" rather as "Normal"

sarin2
Kilo Contributor

Hey there,

I tried creating a Standard Change Request by Creating a Run script in Workflow and invoking Standard Change template. The CR is getting created with the defined values of the Template, however the type is getting set as Normal rather than Standard. When I create a CR manually by clicking on the Template, it creates a CR with type as Standard. I tried setting the type as 'standard' while creating but seems to be not working as well. Any suggestion on how to get the CR as Standard through Run Script. PFA for reference.

TIA

find_real_file.png

find_real_file.png

 

find_real_file.png

 

 

7 REPLIES 7

Allen Andreas
Administrator
Administrator

Hi,

I see you're applying the template AFTER you've stated what type of change_request you want to create.

Please verify that the template is not overwriting it and consider moving your chg.type line to AFTER the apply template.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

@Allen Andreas ,

Nope, Still not working!

Thanks much!

Hi,

Please share your script as of now.

Doesn't really help us to just reply with "Nope, Still not working!".

Please help us with more information, so we can help you.

Please mark reply as Helpful, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Tried both the approaches. Here is the code snippet:

 

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

 


var gr=new GlideRecord('change_request');
gr.addQuery('sys_id','0e1f44fb97d141106c3bbbc3f153af87');
gr.query();
if(gr.next())
{
gr.type='standard';
gr.update();
}