create a subtask with scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2022 01:52 AM
Hello,
I am working on a form that has a list collector variable with servers. I need to create a subtask per selected server with a script and the assignment group should be the one hardcoded below. Below is the script I put together but I'm afraid it is not working. If you have another version for the same functionality, kindly share!
Any help will be appreciated.
Thank you!
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
// var serverArray = [];
var serverList = g_form.getValue('Server_name');
var servers = serverList.split(',');
for(var i=0; i < servers.lenght; i++) {
var gr = new GlideRecord('cmdb_ci');
gr.query('sys_id', servers[i]);
gr.query();
while(gr.next()){
var grTask = new GlideRecord('sc_task');
grTask.initialize();
grTask.request_item = server[i].sys_id;
grTask.description = "test";
grTask.short_description = "Application Access Request - ";
grTask.assignment_group = 'MY ASSIGNMENT GROUP';
grTask.insert();
}
}
//Type appropriate comment here, and begin script below
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2022 10:52 AM
I would never put that in a client script. It goes against every leading practice there is.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2022 11:00 AM
It's in a runscript in a workflow. I'm open to suggestions 🙂