- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2024 08:45 AM
I have an issue with an UI Action and I'm having trouble figuring out how to debug it. I didn't write the UI action, but I've managed to narrow down the issue to one condition in the UI action, but I'm at a loss on how to determine why it is an issue.
The condition that is not working:
The condition that will work:
The original used to work and I assumed it was an ACL write on the state field, but I've checked and the person who is having the issue passes the ACL write for the state field.
Does anyone have any idea where I should start looking or what might be wrong? This is a scoped app; I did a code search and the only place "canWrite() is used is in the UI Actions, and all of them are current.state.canWrite()
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2024 09:10 AM
@gjz Strange this. Ideally, the ACL should trigger. Specially when the state.canWrite() is checked. I recommend you to use the Access Analyser to debug this further and check what all ACLs are triggering for the given user on the record being tested. Also check the ACLs on the state field are Active.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2024 09:24 AM - edited 08-22-2024 09:26 AM
Thanks Sandeep, Access Analyser found the answer. According to the analyzer, it said the field was "read only". The field on the form was just changed to read only, once I removed that the UI action came back.
The reason the field was set as read only on the form is because there is code in the UI Action that controls the value in the state field, the users should not be changing it. I think changing it to current.canWrite() will work since write access to the table requires the same roles.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2024 09:28 AM
@gjz I am glad to know that you managed to find the reason for this behavior.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2024 08:50 AM
current.state.canWrite() doesn't make any sense at all.
The canWrite() applies to an object of the record, and not on any specific field.
It simply shouldn't work😊

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2024 08:57 AM
@AnirudhKumar It does make sense. canWrite() can be used at field level too. Here is the link to the official documentation. https://developer.servicenow.com/dev.do#!/reference/api/washingtondc/server_legacy/c_GlideElementAPI...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2024 09:13 AM
Except that is does, I've seen it in OOB UI Actions.