- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2022 10:14 PM
i have been trying to generate Request ticket from Schedule Jobs using the following script
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
//gives sys_id of catalog item
var item = cart.addItem('5104596487ed0910d0d4ca27cebb35fc', 1);
item.setVariable("requested_for", gs.getUserID());
var rc = cart.placeOrder();
everything is works fine but not displaying the Requested_for value by default. Please help
Solved! Go to Solution.
- Labels:
-
Multiple Versions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2022 12:40 AM
I have written this in a Scheduled Job as you need, but in case you need to write or use this in an Server side function you can do it as well :
Scheduled Job screenshot for reference as well:
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2022 12:43 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2022 12:48 AM
didn't work Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2022 01:05 AM
Hi,
Okay not an issue. For me it is working and have verified it as well. But no issues, please try this script now. This is also working for me:
createRequest();
function createRequest() {
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
//add your requested item to the cart by sys_id of the catalog item
var item = cart.addItem('e212a942c0a80165008313c59764eea1', 1);// Replace your cat item sys id here
var rc = cart.placeOrder();
var getUser = getUserDetails();
var reqRecord = new GlideRecord('sc_request');
reqRecord.get(rc.sys_id);
reqRecord.requested_for = getUser;
reqRecord.update();
}
function getUserDetails() {
var user = new GlideRecord('sys_user');
user.addQuery('sys_id', gs.getUserID());
user.query();
if (user.next()) {
return user.sys_id.toString();
}
}
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2022 01:12 AM
No bro not working , i dnt know why. just copied your code and tried but not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2022 08:46 AM
Hi Shloke, how to auto populate short description and description for this