Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

reference field not working in addquery in ScriptInclude

si21
Tera Guru

Hi experts,

u_region is a reference field in user table with value Europe.

This reference field value is not working in this addQuery in scriptinclude.

Below is code snippet. Please let me know the what went wrong.

 

TIA

 

 

 

isEuropeVisible: function() {
        var gr = new GlideRecord('sys_user');
        //gr.addEncodedQuery('active=true^u_regionLIKEEurope');
        gr.addQuery('active', true);
        gr.addQuery('u_region.u_name', 'Europe');
        gr.addQuery('sys_id', gs.getUserID());
        gr.query();
        if (gr.next()) {
            return true;
        } else return false;
1 ACCEPTED SOLUTION

Musab Rasheed
Kilo Patron

Hello,

Try passing Sys id instead of name.

isEuropeVisible: function() {
        var gr = new GlideRecord('sys_user');
        //gr.addEncodedQuery('active=true^u_regionLIKEEurope');
        gr.addQuery('active', true);
        gr.addQuery('u_region', 'sys id of europe');
        gr.addQuery('sys_id', gs.getUserID());
        gr.query();
        if (gr.next()) {
            return true;
        } else return false;
Please hit like and mark my response as correct if that helps
Regards,
Musab

View solution in original post

1 REPLY 1

Musab Rasheed
Kilo Patron

Hello,

Try passing Sys id instead of name.

isEuropeVisible: function() {
        var gr = new GlideRecord('sys_user');
        //gr.addEncodedQuery('active=true^u_regionLIKEEurope');
        gr.addQuery('active', true);
        gr.addQuery('u_region', 'sys id of europe');
        gr.addQuery('sys_id', gs.getUserID());
        gr.query();
        if (gr.next()) {
            return true;
        } else return false;
Please hit like and mark my response as correct if that helps
Regards,
Musab