Reference Qualifier Issue

Alok Gupta5
Tera Guru
Tera Guru

Hello Team,

 

I need help on reference qualifier.

 

I have created a custom field(Type) of reference type in the RITM table and I have created a custom table where i am storing the combination of Catalog item and type value.

So my requirement is to show the type based on catalog item.

 

If catalog item is Storage then only show story type value in the field it is working perfectly with dependent field.

But issue is coming when catalog Item type is not present in the custom table then we have created some default type that should show. That is not working properly.

 

Can you please help me on that?

 

Regards,

Alok Gupta 

 

1 ACCEPTED SOLUTION

@Alok Gupta5 

try this

Also you should call it like this

javascript: 'sys_idIN' + new getValueforType().getType(current.variables.catVariableName);

var getValueforType = Class.create();
getValueforType.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    initialize: function() {},
    getType: function(cat) {
        gs.info("aloky" + cat);
        var type = [];
        var gr = new GlideRecord('u_category_choice_lookup');
        gr.addQuery('u_item', cat);
        gr.query();
        while (gr.next()) {
            type.push(gr.sys_id.toString());
        }
        if (type.length == 0)
            return 'sysId'; // give here the sysId of default record
        else
            return type.toString();
    },
    type: 'getValueforType'
});

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

7 REPLIES 7

Voona Rohila
Kilo Patron
Kilo Patron

Hi @Alok Gupta5 

Can you please share the Reference Qualifier Logic?


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Hello Voona,

Please see the screen shot below.

AlokGupta5_0-1738926089750.png

 

Ankur Bawiskar
Tera Patron
Tera Patron

@Alok Gupta5 

then you need scripting here to determine if there is any matching record found or not.

If match found then get all the records; if no match found then return 1 sysId

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hello @Ankur Bawiskar Ankur,

 

I have written a script include but not working let me know where to correct.

 

var getValueforType = Class.create();
getValueforType.prototype = Object.extendsObject(AbstractAjaxProcessor,
{
initialize:function(){},
    getType:function(cat){
        gs.log("aloky"+cat);
        var type = "";
        var type1 ="";
        var gr = new GlideRecord('u_category_choice_lookup');
        gr.addQuery('u_item',cat);
        gr.query();
        while(gr.next())
        {
            type =gr.u_type;
         
        }
        return type;

    },
    type: 'getValueforType'
});