Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Unable to fetch users with 'ITIL' role using g_modal in UI action

saisurendra
Tera Contributor

Hi All,

 

I have create a UI form in Service Operations Workspace in which we have 'Approver' reference field. Requirement is to fetch only users with ITIL role in that field. Below is the sample code i tried,

 

Ui action workspace code:

    var approve = [{
        type: 'reference',
        name: 'assigned_to',
        label: getMessage('Approver'),
        mandatory: true,
        reference: 'sys_user',
       query: 'active=false',
        referringTable: 'sc_req_item',
        referringRecordId: g_form.getUniqueValue(),

    }];
 
Kindly help me if we can add any query to get only users with ITIL role
4 REPLIES 4

Ankur Bawiskar
Tera Patron

@saisurendra 

why you want to see active=false users? Should it not be active=true?

try this and add extra condition

var approve = [{
type: 'reference',
name: 'assigned_to',
label: getMessage('Approver'),
mandatory: true,
reference: 'sys_user',
query: 'active=false^roles=itil',
referringTable: 'sc_req_item',
referringRecordId: g_form.getUniqueValue(),

}];

 

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

Hi @Ankur Bawiskar , 


Thank you for the response, but this is not working because 'assigned_to' field has its own reference qualifier and this query ('query: 'active=true^roles=itil') is not helping to fetch all users.

Please help me out if there is a way to make the custom query work overriding the reference qualifier.

 

Thanks,

Sai Surendra

Not applicable

Hi @saisurendra 

 

The only workaround I found until now is to create a new field with the right reference qualifier, and use that to show the right users. It's not optimal, but I think the best we have at this moment.

Shamma Negi
Kilo Sage

Can you try putting the condition on view on reference qualifier if it is default_view then basic reference qualifier condition else if it is workspace view then call another script include.

 

Hope it helps

Regards,Shamma Negi