Display reference choices based on the logged-in user role.

tsoct
Tera Guru

Hello all,

The reference variable field choice should be updated dependent on the logged-in user's role. However, my scripts below do not function. What might have gone wrong?

 

Field reference qualifier:  javascript:new sn_hr_core.INQUtil().checkroleof();

//Script include

var INQUtil = Class.create();
INQUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    checkroleof: function() {

        var TopicAre = '';
        var reqbyuseris = gs.getUserID();
        var chkuserrole = new GlideRecord('sys_user_has_role');
        chkuserrole.addQuery('user', reqbyuseris);
        chkuserrole.addQuery('role.name', 'sn_hr_core.basic');
        chkuserrole.query();

        if (chkuserrole.next()) {
            TopicAre = 'nameINOption1,Option 2,Option 4^active=true';
        } else {
            TopicAre = 'nameINOption5,Option 6,Option 7^active=true';
        }
        return TopicAre;
    },
    type: 'INQUtil'
});

 

2 REPLIES 2

shubhamdubey
Mega Sage

@tsoct 

Are you working or scoped application or global ?

If in global then tried the reference qualifier

 

javascript:new ScriptIncludeName().functionName();

not global but human resource core