Passing variable values from a closed catalog item to a new one via scheluled job
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2023 06:02 AM
I'm trying to copy some of the variable values from a closed catalog item to a new one what is being opened by a scheduled job, but it is not working and leaving the fields empty.
var items = new GlideRecord('sc_req_item');
items.get('1c6bfb061b0739108cb8f646464bcb42');
var gdt = new GlideDateTime(items.variables.end_date);
var today = new GlideDate();
today.getByFormat("MM-dd-yyyy");
if (today.compareTo(gdt.getDate()) == 1) {
var cart = new sn_sc.CartJS();
var item = {
'sysparm_id': '5e653f7b977eb5947065f441f053af96',
'sysparm_quantity': '1',
'variables': {
'requested_for_company' : items.variables.requested_for_company,
'current.requested_for': items.variables.requested_for
}
};
var cartConfirm = cart.orderNow(item);
var cartSubmit = cart.submitOrder(item);
} else {
}
I'm trying to copy from the old closed request item the variable values to the new one it will create, but it is doing it with empty values, could you advise?
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 12:23 AM
Have you checked whether your variables are getting the output or not ? You can put gs.info(items.variables.requested_for) before your if block to check if your are variables are being returned as null or not.
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.