Is there a way to record changes to catalog variables after submission

johnfeist
Mega Sage
Mega Sage

I have occasions where reviewers or fulfillers may need to change a value added by  the requestor.  Other than having to write a lot of AJAX On Change Catalog Client Scripts, is there anyway to note those changes into the activities for the given item (sc_req_item)?

TIA for any insights you can offer.

:{)

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster
1 ACCEPTED SOLUTION

Actually, it's sc_item_option where the BR lives:

if (previous.value != current.value) {
        var var_owner = new GlideRecord('sc_item_option_mtom');
        var_owner.addQuery('sc_item_option', current.sys_id);
        var_owner.query();
        if (var_owner.next()) {
            var itm = new GlideRecord('sc_req_item');
            itm.addQuery('sys_id', var_owner.request_item);
            itm.query();
            if (itm.next()) {
                itm.comments = 'Variable updated ' + current.item_option_new.getDisplayValue() + ' value changed from ' + previous.value.getDisplayValue() + ' to ' + current.value.getDisplayValue() + ' By ' + gs.getUserName();
                itm.update();
            }
        }
    }

This is an after update rule.

:{)

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

View solution in original post

6 REPLIES 6

Did you consider using Variable Ownerships(sc_item_option_mtom) table?

Best Regards
Aman Kumar

Actually, it's sc_item_option where the BR lives:

if (previous.value != current.value) {
        var var_owner = new GlideRecord('sc_item_option_mtom');
        var_owner.addQuery('sc_item_option', current.sys_id);
        var_owner.query();
        if (var_owner.next()) {
            var itm = new GlideRecord('sc_req_item');
            itm.addQuery('sys_id', var_owner.request_item);
            itm.query();
            if (itm.next()) {
                itm.comments = 'Variable updated ' + current.item_option_new.getDisplayValue() + ' value changed from ' + previous.value.getDisplayValue() + ' to ' + current.value.getDisplayValue() + ' By ' + gs.getUserName();
                itm.update();
            }
        }
    }

This is an after update rule.

:{)

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster