creating Request and Tasks from Scheduled Job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 04:19 AM
I used this script to generate request and its respective task from Scheduled Job
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
//give sys_id of catalog item
var item = cart.addItem('016a8e91872d0110d0d4ca27cebb35b2', 1);
cart.setVariable(item,"short_description", ' Monthly Report Update ');
cart.setVariable(item,"description", " Monthly Report Update" );
var rc = cart.placeOrder();
and I wanted to auto populate Assignment group,Assigned to & Sub category as well.
How to do it Please help
- Labels:
-
Multiple Versions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 04:33 AM
Hi rahul
You want to create ctask's for the generated RITM and map values?
You can handle this from your workflow that is linked to your catalog item.
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 04:36 AM
but assigned to is different for different scheduled jobs, there are like 45 jobs to be executed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 04:42 AM
HI Rahul
Can you explain your use case?
Below code is to create sctask for the generated RITM.
var req=rc.number;
var grScReqItem = new GlideRecord('sc_req_item');
grScReqItem.addEncodedQuery("request=" + req);
grScReqItem.query();
var ritm;
if (grScReqItem.next()) {
ritm = grScReqItem.sys_id;
}
var grScTask = new GlideRecord('sc_task');
grScTask.initialize();
grScTask.request_item = ritm;
grScTask.assignment_group = '';//map your group here
//map all your fields here
grScTask.insert();
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 04:55 AM
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
//give sys_id of catalog item
var item = cart.addItem('016a8e91872d0110d0d4ca27cebb35b2', 1);
cart.setVariable(item,"short_description", ' Monthly Report Update ');
cart.setVariable(item,"description", " Monthly Report Update" );
var rc = cart.placeOrder();
var grScReqItem = new GlideRecord('sc_req_item');
grScReqItem.addEncodedQuery("request=" + rc);
grScReqItem.query();
var ritm;
if (grScReqItem.next()) {
ritm = grScReqItem.sys_id;
}
var grScTask = new GlideRecord('sc_task');
grScTask.initialize();
grScTask.request_item = ritm;
grScTask.assignment_group = '9efc96a71b2909105cf40f6cdc4bcb45';//map your group here
grScTask.assignment_to = 'ebb5217a87cd4910d0d4ca27cebb3505';
grScTask.u_sub_category = 'Tasks';
//map all your fields here
grScTask.insert();
I tried to execute this , but not populating assgnment group, assigned to and sub category