Passing variable values from a closed catalog item to a new one via scheluled job

Piotr Kuziel
Kilo Contributor

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

Amit Verma
Kilo Patron
Kilo Patron

Hi @Piotr Kuziel 

 

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.