Advanced Reference Qualifier Based on Another RITM Variable

Wasdom_Kung
Tera Guru

Hello,

 

I have two catalog items limited to these variables:

Catalog item A:

Ref Variable - "Manager 1" = sys_user table

 

Catalog item B:

Ref Variable - "Manager 2" = sys_user table

Ref Variable - "RITMS" = sc_req_item table

 

I want variable "RITMS", to limit itself to all open requests that have the same variable value selected, example:

 

Catalog item A request = Manager 1 value is James

Catalog item B request = Manager 2 value is James

"RITMS" field shows all open requested where variable "Manager 1" of catalog item B matches open requests from catalog item A where variable value is also James.

 

Could someone help with this? I currently have a script that works similar to this but doesn't account for specific outcomes, whereas the above would cover all bases.

2 REPLIES 2

Anand Kumar P
Giga Patron

Hi @Wasdom_Kung ,

Try below script create new script include and in reference qualifier use below script

javascript: 'sys_idIN' + new YourScriptIncludeName().getOpenRITMs(current.variables.manager_1)
 getOpenRITMs: function(manager1Value) {
        var ritms = [];
        var gr = new GlideRecord('sc_req_item');
        gr.addQuery('active', true); 
        gr.addQuery('request.opened_by', manager1Value);
gr.addQuery('cat_item','sys_idofcatalog_item1);
        gr.query();
        while (gr.next()) {
            ritms.push(gr.getUniqueValue()); 
        }

        return JSON.stringify(ritms);
    }

Please mark it as helpful and solution proposed if its serves your purpose.

Thanks,

Anand

Hi Anand,

 

Thanks for providing this! I've created the script and amended the reference qualifier but isn't populating, I'll put them below:

 

Edit: It may be worth noting that the person that opens the request isn't necessarily the person in the manager field.

 

Script Include:
LOTH_GetManagerDetails

 

var LOTH_GetManagerDetails = Class.create();
LOTH_GetManagerDetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    getOpenRITMs: function(u_manager_name) {
        var ritms = [];
        var gr = new GlideRecord('sc_req_item');
        gr.addQuery('active', true);
        gr.addQuery('request.opened_by', u_manager_name);
        gr.addQuery('cat_item', '4123ac00db3d84105a34241848961971');
        gr.query();
        while (gr.next()) {
            ritms.push(gr.getUniqueValue());
        }

        return JSON.stringify(ritms);
    }
});

 

 

Reference qualifier:

 

javascript: 'sys_idIN' + new LOTH_GetManagerDetails().getOpenRITMs(current.variables.u_select_your_manager);

 

 

 

Clarification:

Catalog item A
u_manager_name - sys_user

 

Catalog item B

u_select_your_manager - sys_user

u_select_reference - sc_requested_item

 

u_select_reference should display all open requested items where u_manager_name is the same value as u_select your manager.