.

Greg L
Tera Contributor

 

.

4 REPLIES 4

G Ponsekar
Giga Guru

Hi @Greg L .

 

Can you update your script like below and check?

// Define the list of restricted record numbers
var restrictedRecords = ['IMS0010267', 'IMS0010268']; // Add new records here as needed

// Check if the current record number is in the restricted list
if (restrictedRecords.indexOf(current.number.toString()) > -1) {
    // If it is a restricted record, require the admin role
    if (gs.hasRole('admin')) {
        answer = true; // Admin can view    
}
else { answer = false; // Non-admin cannot view } } else { // If it is NOT a restricted record, allow general access (based on other ACLs or default rules)
answer =
true; }

 

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!

 

Thanks, GP

James Chun
Kilo Patron

Hi @Greg L,

 

What you are trying to do is probably not scalable as you will need to modify the script everytime new records need to be restricted.

 

How about you add a custom field (like a checkbox) or use some conditions (e.g. caller is a VIP) and simply use your ACL to restrict access when the checkbox or condition is true?

This way, you don't have to update your ACL everytime.

 

Cheers

.

Right, no worries.

There is always the easier way of using the condition builder instead of a script but you can use the following script:

 

var arrUtil = new ArrayUtil();
var restrictedRecords = ['IMS0010267'];
if (arrUtil.indexOf(restrictedRecords, current.number) != -1 && !gs.hasRole('admin')) {
    answer = false;
} else {
    answer = true;
}

Not sure why indexOf doesn't work so had to use the ArrayUtil.

 

Hope that helps, cheers