script to check user against field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2024 01:27 PM
Excuse my likely incorrect terminology... I haven't looked at JS in years. I'm trying to lock down asset records so only the assigned property custodian can edit (with the exception of the Comments field which I want to remain writable by anyone).
I know the getUserID() method will call the sys_id of the current User and I can check that against the sys_id of the alm_asset.custodian field and return TRUE if they match.
If that all sounds feasible, what's the actual script? Or, even better, is there a non-script solution for this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2024 03:28 AM
You would need to specify each field in the script, and client scripts allow access by the same person through other methods, so a better approach is to create a write ACL on the table. These can be a sticky wicket, but try something like this:
My Xanadu screen will look different than yours, but the Operation, Admin override, Active, Advanced, and Name (table) and fields (*) are the most important. Your script would look like this:
answer = current.custodian == gs.getUserID();
You would then need another ACL on just the comments field to allow write access to anyone with the snc_internal role.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2024 03:34 AM
Why use a script here? For some reason I see this a lot, but you can just use the data conditions and set the condition 'custodian is dynamic me'. No need for scripting at all.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2024 02:39 PM
I really appreciate the response, and it does make complete sense. I believe I've set it up that way, but I don't see any change in the behavior. Even if I take off the Admin override, everyone can edit all the records. Is there another step I have to do to apply the new ACL? Does it take some time to go into effect?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2024 02:42 PM
I really appreciate the response, and the syntax makes sense to me. I think I have it entered correctly, but I don't see any change in the behavior. Even if I take off the Admin override, everyone can edit all the records. What Mark mentions below also makes sense but has the same result as the script option. Is there a step I'm overlooking?