Unable to create a standard change request record using script.

Chintha Murali
Kilo Expert

I am trying to create a standard change request record using script. But the change is getting created as a normal change. 

var chg = new GlideRecord('change_request');
chg.initialize();
chg.type = "standard";
chg.std_change_producer_version = '16c2273c47010200e90d87e8dee49006'; // Sys ID of the Standard Change Templates version
chg.applyTemplate('Clear BGP sessions on a Cisco router');
chg.insert();

 

I am unable to set the model to standard. Please help me with this.

 

1 ACCEPTED SOLUTION

Hi @Chintha Murali krishna 

In your First screenshot as well the Change Record got created successfully as shown in red below:

find_real_file.png Model value is taken from below Table which is an OOB table and sys id which I have provided should remain same for you as well, but worth double checking it again.

Navigate to the Model table by typing "chg_model.LIST" in Application Navigator menu as shown below:

find_real_file.png

Now Right click on Standard and copy the sys id which you will need to use it in your script shared above:

find_real_file.png

Say if you do not see Standard in your Change Model table then you can import the attached XML record which is from a OOB ServiceNow PDI instance which will add your Standard Model and relevant states linked to this model.

Result:

find_real_file.png

find_real_file.png

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

8 REPLIES 8

Hi @shloke04 ,

Thank you for taking time and answering.

I have tried on my PDI, it is not working for me. May be I am taking the sys_id from a wrong place. Could you please tell me how to get the sys_id of the "Standard Model"?

 

I am getting the following error if I try on my PDI.

find_real_file.png

 

 

I tried executing again. change is getting created but model is being set to empty.

find_real_file.png

Hi @Chintha Murali krishna 

In your First screenshot as well the Change Record got created successfully as shown in red below:

find_real_file.png Model value is taken from below Table which is an OOB table and sys id which I have provided should remain same for you as well, but worth double checking it again.

Navigate to the Model table by typing "chg_model.LIST" in Application Navigator menu as shown below:

find_real_file.png

Now Right click on Standard and copy the sys id which you will need to use it in your script shared above:

find_real_file.png

Say if you do not see Standard in your Change Model table then you can import the attached XML record which is from a OOB ServiceNow PDI instance which will add your Standard Model and relevant states linked to this model.

Result:

find_real_file.png

find_real_file.png

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hi @Chintha Murali krishna 

Let me know if you are stuck and if your query is resolved then please mark my answer as correct and close this thread for others.

Regards,

Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke