Catalog approval change

manish986
Tera Contributor

Hi Community People,

 

I have a requirement where I have to change one approver to another approver. But before that I have to create a list of the catalog items that were linked to the approver.

 

How can we achieve this as I tried to make a report but I am just getting the RITM's where the approver has approved and not the catalog.

 

Thanks in advance 

 

 

4 REPLIES 4

Harshal Aditya
Mega Sage

Hi @manish ,

 

Hope you are doing well.

 

Could you please elaborate on the requirement ?

Do you want to update the sysapproval_approver records with new approvers

 

Regards,

Harshal

Hi @Harshal Aditya 

Thank you for your reply.

Right now I just want the list of the catalog items that were linked to the approver.(the existing approver).

 

Thanks 

Manish

 

Hi @manish986 ,

 

Using reports it might be difficult as you may need to create database view.

Maybe as suggested by Tushar you could also use fix script

Tushar
Kilo Sage

Hi @manish986 ,

 

something like this should help -

 

var approverSysId = 'approver_sys_id';

var ritmList = [];

// Query the Approval Task table to find tasks associated with the approver
var approvalTask = new GlideRecord('sysapproval_approver');
approvalTask.addQuery('approver', approverSysId);
approvalTask.query();

while (approvalTask.next()) {
    var ritmSysId = approvalTask.parent.toString(); // Get the RITM sys_id associated with the task
    var ritm = new GlideRecord('sc_req_item');
    if (ritm.get(ritmSysId)) {
        // Retrieve the catalog item details from the RITM and add it to the list
        var catalogItem = ritm.cat_item.getDisplayValue();
        ritmList.push(catalogItem);
    }
}

// ritmList now contains the list of catalog items associated with the specified approver
gs.info('Catalog Items for Approver ' + approverSysId + ': ' + ritmList.join(', '));

 

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Regards,
Tushar