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
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  ||  9x 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

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.


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

Shamma Negi
Kilo Sage
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