- 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-04-2022 11:54 PM
no use
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2022 12:03 AM
not worked
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2022 08:47 AM
Hi Martin , can you help me how to auto populate Short description and Description
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2022 12:38 AM
Hi,
Please use the script below to achieve your requirement:
createRequest();
function createRequest() {
var cart = new Cart();
var item = cart.addItem('e212a942c0a80165008313c59764eea1'); // Replace your catalog item sys id here
var getUser = getUserDetails();
cart.setVariable(item, 'requested_for', getUser);
var rc = cart.placeOrder();
}
function getUserDetails() {
var user = new GlideRecord('sys_user');
user.addQuery('sys_id', gs.getUserID());
user.query();
if (user.next()) {
return user.sys_id.toString();
}
}
This is working for me as shown below:
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: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