How to create 4 tasks in incident by UI action Button on a form level?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2024 10:40 PM
How to create 4 tasks in incident by UI action Button on a form level through scripting?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2024 10:46 PM - edited ‎05-01-2024 10:47 PM
Hello,
You can use below code in UI Action.
var grtask= new GlideRecord('incident_task');
for(var i = 0; i<4;i++){
grtask.initialize();
grtask.short_description=current.short_description;
grtask.assignment_group=current.assignment_group;
grtask.insert();
}
current.worknotes='Incident task is created-'+grtask.number;
If my answer has helped you in any way please mark it as correct or helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2024 12:07 AM
Hi @krishna svg ,
Create One UI Button "Create Task"
Define the condition on which you want to be appear or visible UI button
Use this script for incident task
var grtask= new GlideRecord('incident_task');
for(var i = 0; i<4;i++){
grtask.initialize();
grtask.incident=current.sys_id;//Link the incident with task record
grtask.short_description=current.short_description;
grtask.assignment_group=current.assignment_group;
grtask.insert();
grtask.update();
}
current.worknotes='Incident task is created-'+grtask.number;
current.update();
action.sendRedirectURL(cureent);
If you want to create task only then
use this script
var grtask= new GlideRecord('task');
for(var i = 0; i<4;i++){
grtask.initialize();
grtask.parent=current.sys_id;//Link the incident with task record
grtask.short_description=current.short_description;
grtask.assignment_group=current.assignment_group;
grtask.insert();
grtask.update();
}
current.worknotes='Incident task is created-'+grtask.number;
current.update();
action.sendRedirectURL(cureent);
Regards,
Seraj

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2024 12:49 AM
Hi @krishna svg ,
I tried your problem in my PDI and it works for me please refer below images and script
I create UI action which is not client callable and added below script
var taskGR = new GlideRecord('task');
for(var i = 0; i<4;i++){
taskGR.initialize();
taskGR.parent = current.sys_id;//Link the incident with task record
taskGR.short_description = current.short_description;
taskGR.description = current.description;
taskGR.assignment_group = current.assignment_group;
taskGR.insert();
}
Result :
When I click UI Action - Create Task it created 4 tasks
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak