Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Problem Form, added ref field 'Problem Owner' & can only select those users who have that role???

Philip Owen
Tera Contributor

problem_manager.pngHello all,

 

I have created a Problem Owner (reference field), to the Problem Manager form, I have created some code that should only filter those users who have the Problem Manager role. I have created the Reference qualifier = javascript:new prbFunctions().getprbmanagers(). 

 

My script include code is: 

var prbFunctions = Class.create();
prbFunctions.prototype = {
    initialize: function() {
    },
getprbmanagers: function(){
var pmanagers='';
    var gr = new GlideRecord('sys_user_has_role');
    gr.addQuery('role','b573c1f9538823004247ddeeff7b12e0');  //problem manager role sys_id
    gr.query();
    while(gr.next())
        {
            pmanagers = pmanagers + ','+ gr.user;
        }
    var result = 'sys_idIN' + pmanagers;
    return result;
},

    type: 'prbFunctions'
};
 
 
When I select the new reference field Problem Owner I am still getting all roles and not the filtered Problem Manager roles. Where have I gone wrong with this???? I have gone over it 3 times. 
1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Philip Owen 

this should help directly without script

like this; give the exact role name

AnkurBawiskar_0-1733500002400.png

 

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

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@Philip Owen 

this should help directly without script

like this; give the exact role name

AnkurBawiskar_0-1733500002400.png

 

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

Philip Owen
Tera Contributor

Yep, this has worked, I was trying to do it the hard way for some reason as I'm learning JavaScript.