How to query Change Request record by condition (current user is in group of creator)?

Akkapolk
Giga Expert

Group1 has User1, User2 and User5 as picture below.

find_real_file.png


Group2 has User3, User4 and User5 as picture below.

find_real_file.png

 

Change Request number CHG0030046 is created by User1 and CHG0030047 is created by User3 as picture below.

find_real_file.png

 

How to query Change Request record by condition (current user is in group of creator)?
User1, User2 can see only Change Request number CHG0030046.
User3, User4 can see only Change Request number CHG0030047.
User5 can see both Change Request number CHG0030046 and CHG0030047.

 

For example: Can see only Change Request number CHG0030046 when User1 login.

find_real_file.png

10 REPLIES 10

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

For this you need to write query business rule and script as below

var groups = gs.getUser().getMyGroups;

groups = groups.toString();

current.addQuery('assignment_group', 'IN', groups);

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Hi Ankur,

 

Where to write business rule for this page? Please help to suggest me.

 

Note: I added my expected example to this topic above.

For example: Can see only Change Request number CHG0030046 when User1 login.

find_real_file.png

Hi,

Write query business rule on change_request table.

test it once

Regards

Ankur

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

Thank you. I will check, test and reply within this month.