Create ACL not working on table level.

pranay_14
ServiceNow Employee
ServiceNow Employee

I have a custom table where I need to create records of specific source_type 'XY' only and owner is not empty . I have created an create ACL with script condition as 

answer = (current.owner != '' && (current.isNewRecord() || current.source_type == 'XY'));
 
The source_type is never checked. How to fix this?
7 REPLIES 7

Di Zhang
Tera Guru

actually I don't suggest to use ACL to implement the complex condition in create. You can try set condition in "New" UI action. 

pranay_14
ServiceNow Employee
ServiceNow Employee

@Di Zhang could you please elborate on this a bit more.

when you create a record, you need to click the New button in form. So you can add your condition to condition of "New" UI action.

anand-bhosle
Tera Guru

@pranay_14 

You're on the right track with your ACL script condition, but there's a common gotcha in ACL evaluations that might be causing your issue:

Problem:

current.source_type == 'XY' might not be working because:

  1. source_type may be a reference or choice field, and you're comparing it incorrectly.

  2. ACL conditions can behave unexpectedly if field values haven't been fully populated yet.

Use current.source_type.toString() to ensure you're comparing strings properly.
answer = (current.owner != '' && (current.isNewRecord() || current.source_type.toString() == 'XY'));

Add some logs and try.