Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Query Business rule to restrict record on list view

saggi
Tera Contributor

Hi ,

I using this query to restrict records shown in a list view to non itil users.
The Query BR I has created on Incident table ,I have modified the script .
var userId = gs.getUserID();
var gr = new GlideRecord('sys_user');
gr.addEncodedQuery('sys_id='+userId);
gr.query();
if(gr.next()) {
var userEmail = gr.getValue('email');
if(userEmail != 'abc@gmail.com') {
current.addQuery('category', 'inquiry');
}
My intention is to show only those records which has the same email address on incident form.
if logged in user email address is abc@gmail.com(on sys_user), then he will only see incident
which has this email of abc@gmail.com on incident form else he doesn't see any record.
Please suggest a suitable query.
2 REPLIES 2

SaiRaviKiran Ak
Tera Guru

Hi,

 

You have to create business rule on the incident table to restrict incident list view records.

 

Thanks,

Ravi 

Shishir Srivast
Mega Sage

I believe you can try with before Query BR with below condition and script. You may have to replace the called_id.email with you custom filed if you do not have email field as a dotwalking field from the caller_id. find_real_file.png