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 05:56 AM
by using this i can create a new ticket (req,ritm & SCtask)
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 able to populate short description and Description
but couldn't populate Assignment group, Assigned to and sub category
Tasks backend value is the same
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 05:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 06:02 AM
oh looks like you want to update existing CTASK.
try this code.
var req=rc.number;
var grScReqItem = new GlideRecord('sc_req_item');
grScReqItem.addEncodedQuery("request.number=" + req);
grScReqItem.query();
var ritm;
if (grScReqItem.next()) {
ritm = grScReqItem.sys_id;
}
gs.info("RITM Info "+ritm);
var grScTask = new GlideRecord('sc_task');
grScTask.addQuery('request_item', ritm);
grScTask.query();
while (grScTask.next()) {
//grScTask.request_item = ritm;
grScTask.assignment_group = '9efc96a71b2909105cf40f6cdc4bcb45';//map your group here
grScTask.assigned_to = 'ebb5217a87cd4910d0d4ca27cebb3505';
grScTask.u_sub_category = 'Tasks'; //use backend value
grScTask.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 06:04 AM
no i want to create the sc task so please suggest me what to add to my present code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 06:10 AM
Can you share your complete requirement please with screenshots if possible.
you mentioned you're able to populate short description and description, can you show how that is mapped?