Create a change request through Script

Reena Kumari2
Tera Contributor

Hi Team,

My requirement is to create all 3 types of change through background script. Please advice on this.

 

Thanks&Regards

Reena Kumari

1 ACCEPTED SOLUTION

 

I got the issue, chg_model value was missing, try below:

Emergency:

var chg = new GlideRecord('change_request');
chg.initialize();
chg.type = 'emergency'; // replace if you want to create another tupe of change;
chg.short_description = "test"; // replace for any other short desc;
chg.chg_model='62d10fa1c303101035ae3f52c1d3aec1';
chg.insert(); 

 

Standard:

var chg = new GlideRecord('change_request');
chg.initialize();
chg.type = 'standard'; // replace if you want to create another tupe of change;
chg.short_description = "test"; // replace for any other short desc;
chg.chg_model='e55d0bfec343101035ae3f52c1d3ae49';
chg.insert();


Please mark the answer correct/helpful accordingly.


Raghav
MVP 2023

View solution in original post

8 REPLIES 8

RaghavSh
Kilo Patron

Follow below code:

var chg = new GlideRecord('change_request');
chg.initialize();
chg.type = 'normal'; // replace if you want to create another tupe of change;
chg.short_description = "test";  // replace for any other short desc;
chg.insert();

Raghav
MVP 2023

Hi Raghav,

Your script is working fine for creating normal change but it's not creating emergency and standard change , if I change the type in script. Please advice.

Thanks

Reena Kumari

 

did you change the below line for standard and emergency:

 

chg.type = 'emergency';  // for emergency change 
chg.type = 'standard';  // for standard change 

 

 


Raghav
MVP 2023

yes I have changed

var chg = new GlideRecord('change_request');
chg.initialize();
chg.type = 'standard'; // replace if you want to create another tupe of change;
chg.short_description = "test"; // replace for any other short desc;
chg.insert();

var chg = new GlideRecord('change_request');
chg.initialize();
chg.type = 'emergency'; // replace if you want to create another tupe of change;
chg.short_description = "test"; // replace for any other short desc;
chg.insert();