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

Amit Verma
Kilo Patron
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


Please mark this response as correct and helpful if it assisted you with your question.

View solution in original post

4 REPLIES 4

Amit Verma
Kilo Patron
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


Please mark this response as correct and helpful if it assisted you with your question.

Tai Vu
Kilo Patron
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
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 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

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/atul_grover_lng [ Connect for 1-1 Session]

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