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

Hi,

Have you confirmed that the sys_id of the template you are using is a standard change template?

If not, please use that.

I think the template is where the issue may be.

You can also test without using a template and see if you can create the change by just specifying the type, this will help narrow it down that it may be the template locking it in to normal.

Also, please consider adding this to your script as well:

gr.std_change_producer_version = 'sys_id'; // Sys ID of the Standard Change Templates version

https://community.servicenow.com/community?id=community_question&sys_id=79818d31db090cd41cd8a345ca96...

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


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

Hi,

I had been passing the sys_id of the template, still not working.

 

var chg = new GlideRecord('change_request');
chg.initialize();
chg.std_change_producer_version = current.variables.select_change_template.current_version;
var tempName = current.variables.select_change_template.getDisplayValue();
chg.applyTemplate(tempName);

Hi,

Please check your values for that variable to ensure it's correct data.

I also gave a link to another post you can review. Where they're doing the same thing and it's working.

Something is must likely incorrect with your data, perhaps.

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


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