- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 08:41 AM
Hi there,
I'm trying to restric ACLs permissions for Demand RIDACs items according to demand record permissions. I need to use the canWrite() function and it should look the parent demand record. I have builded a script but it doesn't work
var answer=false;
// Check if current user can edit parent
if (parent.canWrite())
{
answer=true;
}
Do you know what is wrong?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2023 04:42 PM
Ok, I have found the solution. First you need to refert to the parent record with getRefRecord() and then check permissions with canWrite so:
var parent= current.parent.getRefRecord();
answer = parent.canWrite();
it should work

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 11:47 AM
@Leonel Sandroni Can you check if the record has a parent assigned to it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 12:05 PM
Yes, it has a parent record
Also I have checked the write ACLs in dmn_demand (parent table) and it seems to be right
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 12:16 PM - edited 07-25-2023 12:16 PM
The script looks correct. Just adding some lines below so that you can add logs and check
var answer = false;
if (current.parent) {
gs.log("Parent exists. Parent canWrite(): " + current.parent.canWrite());
if (current.parent.canWrite()) {
answer = true;
gs.log("User can edit parent demand record.");
}
} else {
gs.log(" Parent record not found or parent field is empty.");
}
In case the logs don't help and everything seems right. Please enable 'Debug security rules' and check whether there are any other ACLs that match and are restricting the permissions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 01:11 PM
I have debugged the acls and I have found this script condition is the problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2023 04:42 PM
Ok, I have found the solution. First you need to refert to the parent record with getRefRecord() and then check permissions with canWrite so:
var parent= current.parent.getRefRecord();
answer = parent.canWrite();
it should work