How we can provide write access to their own records by using ACL

Ashok59
Tera Contributor

I need to provide write access to hardware table based on owned by field. Could you please assist me on this.

 

Regards,

Ashok.

2 ACCEPTED SOLUTIONS

Hi @Ashok59 ,

 

You can achieve this by creating a write ACL on alm_asset table with None.

U need to select advanced & under script section u can write this script

 

if (current.owned_by == gs.getUserID()){

answer = true;

}

 

Thanks,

Danish

 

 

 

 

View solution in original post

Aniket Chavan
Tera Sage
Tera Sage

Hello @Ashok59 ,

You can give a try to the script below in the write ACL on alm_asset table,

var ownedByUser = current.owned_by.user; // Assuming 'owned_by' is a reference field to the User table

if (ownedByUser == gs.getUserID()) {
    answer = true;
} else {
    answer = false;
}

 

If, despite using the script above, you are still facing issues with access, it's advisable to investigate existing ACLs on the write function that might be conflicting with your new one. Additionally, you can leverage the "Debug Security Rules" feature to identify all ACLs running on the current record. This can help pinpoint any conflicts or interactions between different rules and guide you in resolving the access-related challenges effectively.


This version provides a more detailed explanation of the suggested script and offers additional guidance on troubleshooting and debugging potential conflicts with existing ACLs.

AniketChavan_2-1705822139225.png

 

AniketChavan_0-1705821949528.png

 

Let me know your views on this and Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks,

Aniket

 

 

View solution in original post

7 REPLIES 7

Aniket Chavan
Tera Sage
Tera Sage

Hello @Ashok59 ,

You can give a try to the script below in the write ACL on alm_asset table,

var ownedByUser = current.owned_by.user; // Assuming 'owned_by' is a reference field to the User table

if (ownedByUser == gs.getUserID()) {
    answer = true;
} else {
    answer = false;
}

 

If, despite using the script above, you are still facing issues with access, it's advisable to investigate existing ACLs on the write function that might be conflicting with your new one. Additionally, you can leverage the "Debug Security Rules" feature to identify all ACLs running on the current record. This can help pinpoint any conflicts or interactions between different rules and guide you in resolving the access-related challenges effectively.


This version provides a more detailed explanation of the suggested script and offers additional guidance on troubleshooting and debugging potential conflicts with existing ACLs.

AniketChavan_2-1705822139225.png

 

AniketChavan_0-1705821949528.png

 

Let me know your views on this and Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks,

Aniket

 

 

Why script this? What is the upside of scripting this, if you can easily set conditions to 'owned_by is dynamic me'. Just curious, since both should work, but conditions are less error prone (typos and such).


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Mark Manders
Mega Patron

Then you can do it as I already said: add a 'write' acl to your hardware table and add in the conditions part 'owned by' is dynamic 'me'. That will validate the table against the logged in user. Not sure why others are telling you to script, because these are simple conditions on the ACL record.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark