Populate requested for the same user in Requested by.

NeilCarloB
Tera Contributor

Hello,

I have requirement on catalog item the when request is raise the requested for in RITM table is different from the requested by in variable set.

I've written some script and it working on request but in RITM it didnt work.

(function executeRule(current, previous /*null when async*/) {

    var specificCatalogItemSysId = 'bbc4636d1bfc51500531ed7de54bcb6d';  

    var grRITM = new GlideRecord('sc_req_item');
    grRITM.addQuery('request', current.sys_id); // Query for request items linked to the current request
    grRITM.addQuery('cat_item', specificCatalogItemSysId); // Add condition to filter by specific catalog item
    grRITM.query();

    // Loop through the found RITMs
    while (grRITM.next()) {
        // Check if the 'request_for' variable is set
        if (!JSUtil.nil(grRITM.variables.request_for)) {
            // If 'request_for' is set, update the 'requested_for' field on the current request
            current.requested_for = grRITM.variables.request_for;
		grRITM.requested_for = grRITM.variables.request_for;
			
        }
		
    }


})(current, previous);

check.pngcheck 2.png

0 REPLIES 0