Add new SCTASK(s) to RITM

Leon Els
Tera Expert

Greetings, 
I am trying to create a UI Action that will allow the Service Desk to add Additional SCTASK(s) to any Open RITM.
Thank you in advance for any guidance 🙂 

1 ACCEPTED SOLUTION

Amrit4
Tera Guru

Copy the below script to your UI action:

UI Action name - " whatever "

Table - sc_req_item

 

Client - keep it un-ticked (false)

 

 

 

var sc = new GlideRecord('sc_task');
sc.newRecord();
sc.setValue('short_description', current.getValue('short_description'));
sc.setValue('description', current.getValue('description'));
sc.setValue('assignment_group', current.getValue('assignment_group'));
sc.setValue('request_item', current.getValue('sys_id'));
sc.setValue('request', current.getValue('request'));

// add required fields

var recSysId = sc.insert(); // create catalog task

// to copy variable on catalog task
var gr = new GlideRecord('sc_item_option_mtom');
gr.addQuery('request_item.numberSTARTSWITH' + current.getValue('number'));
gr.query();
while (gr.next()) {

var grt = new GlideRecord('sc_item_variables_task');
grt.newRecord();
grt.setValue('task', recSysId);
grt.setValue('variable', gr.sc_item_option.item_option_new.toString());
grt.insert();
}

 

 

 

 

Please be kind enough to mark my answer correct and helpful.

View solution in original post

9 REPLIES 9

Amrit4
Tera Guru

Copy the below script to your UI action:

UI Action name - " whatever "

Table - sc_req_item

 

Client - keep it un-ticked (false)

 

 

 

var sc = new GlideRecord('sc_task');
sc.newRecord();
sc.setValue('short_description', current.getValue('short_description'));
sc.setValue('description', current.getValue('description'));
sc.setValue('assignment_group', current.getValue('assignment_group'));
sc.setValue('request_item', current.getValue('sys_id'));
sc.setValue('request', current.getValue('request'));

// add required fields

var recSysId = sc.insert(); // create catalog task

// to copy variable on catalog task
var gr = new GlideRecord('sc_item_option_mtom');
gr.addQuery('request_item.numberSTARTSWITH' + current.getValue('number'));
gr.query();
while (gr.next()) {

var grt = new GlideRecord('sc_item_variables_task');
grt.newRecord();
grt.setValue('task', recSysId);
grt.setValue('variable', gr.sc_item_option.item_option_new.toString());
grt.insert();
}

 

 

 

 

Please be kind enough to mark my answer correct and helpful.

Thank you SO much for your guidance!  I am so fortunate to have 3 responses and will advise soon   🙂

 

Go my way. Trust me its working i have tried

Amrit4_0-1681508025602.pngAmrit4_1-1681508055291.png

Please be kind enough to mark the solution Correct and helpful

Kudos my friend, thank you!!