- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 10:06 AM
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.
Solved! Go to Solution.
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 11:33 PM
Hi
In your First screenshot as well the Change Record got created successfully as shown in red below:
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:
Now Right click on Standard and copy the sys id which you will need to use it in your script shared above:
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:
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 10:43 AM
This is working fine in OOB instance. Better check, is there any business rule running in your instance to set this change type.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 09:37 PM
I tried in my PDI, it creates a normal change. But I need a Standard change to be created.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 11:00 AM
Could you please check whether type is mentioned your template - Clear BGP sessions on a Cisco router. If yes, you can remove it and try
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 11:49 AM
Hi
Please update your script as below and it will work for you. I have tested this in my PDI and works fine:
var chg = new GlideRecord('change_request');
chg.initialize();
chg.type = "standard";
chg.chg_model = 'e55d0bfec343101035ae3f52c1d3ae49'; // Standard Model sys id
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();
Reason why it was updating as Normal because there is a field on Change Form name as Model which has a default value set as Normal and that drives the Type of Change request as well.
So you need to explicitly set the Model and Type both as Standard.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke