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

Hi,

Any update on this?
Can you mark my answer as correct, helpful if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.

Regards
Ankur

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

asifnoor
Kilo Patron

Hi,

Write a query BR on change_request table as per this screenshot.

find_real_file.png

Mark the comment as a correct answer and helpful once worked.

 

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

Okay. Could you mark the comment as a correct answer and helpful once worked.

Vaibhav
Giga Guru

Hi Akkapolk,

Please try following script with Before - Query: business rule.

var allCHG=[];
var grpId = gs.getUser().getMyGroups();

var chgREQ= new GlideRecord('change_request');
chgREQ.addQuery('assignment_group',grpId);
chgREQ.query();
while(chgREQ.next()){
 // gs.warn("CHG are :" + chgREQ.number +" ::: "+chgREQ.assignment_group);
  allCHG.push(chgREQ.getValue('number'));
}
gs.warn('@VC allCHG'+allCHG);

var CHG = current.addQuery('number','IN',allCHG);

Please mark a reply as correct/helpful if helpful.