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

@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

Thanks @Ankur Bawiskar It is working as expected.

Just one more thing how can we pass multiple default types.

I have 5 default types.

Can i pass through property?

 

or any other way.

 

I am doing like that 

  gr.query();
        while (gr.next()) {
            type.push(gr.sys_id.toString());
        }
        if (type.length == 0)
            return gs.getProperty('DefaultValues'); // give here the sysId of default record
        else
            return type.toString();

@Alok Gupta5 

that property should have comma separated sysIds and property type should be String.

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