Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Incident task creation

Ketan Pandey
Tera Expert

Could you please suggest hoe to create a plan incident and incident task via script 

1 ACCEPTED SOLUTION

vermaamit16
Kilo Patron

Hi @Ketan Pandey 

 

Below script will work to create a new incident and associate an incident task to it :

 

var inc = new GlideRecord('incident'); 
inc.initialize(); 
inc.short_description = 'Test Inc'; 
var inc_sys = inc.insert();
var incTask = new GlideRecord('incident_task'); 
incTask.initialize(); 
incTask.short_description = 'Test Inc Task'; 
incTask.parent = inc_sys;
incTask.incident = inc_sys;
incTask.insert();

 

Thanks & Regards

Amit Verma

Thanks and Regards
Amit Verma

View solution in original post

4 REPLIES 4

vermaamit16
Kilo Patron

Hi @Ketan Pandey 

 

Below script will work to create a new incident and associate an incident task to it :

 

var inc = new GlideRecord('incident'); 
inc.initialize(); 
inc.short_description = 'Test Inc'; 
var inc_sys = inc.insert();
var incTask = new GlideRecord('incident_task'); 
incTask.initialize(); 
incTask.short_description = 'Test Inc Task'; 
incTask.parent = inc_sys;
incTask.incident = inc_sys;
incTask.insert();

 

Thanks & Regards

Amit Verma

Thanks and Regards
Amit Verma

Tai Vu
Kilo Patron

Hi @Ketan Pandey 

What is your business use case to create Incident Task using script?

 

Cheers,

Tai Vu

Pravershi
Tera Contributor
Hi @Ketan Pandey ,
You can use this script

var gr = new GlideRecord('incident');
gr.initialize();
//gr.description = 'Testing';
//specify all details you want to fill in incident form using gr.field_name = 'value you want to insert';
gr.insert();

 

Dr Atul G- LNG
Tera Patron

Hi @Ketan Pandey 

 

I respect  the decision , but I am not in favour to use script if work can be done in LOW CODE / NO CODE. You can do via Flow designer 

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************