Determining create ACL to a table, based on the state of a parent table.

sshah10
Kilo Contributor

Hi all,

I was wondering if somebody could help me solve this issue I am facing, when attempting to define a create ACL, for a child table, where create permissions need to be determined based on the state of a parent table, and the role assigned to a user.

Currently, records on the parent table have a related list linking to the child table, and depending on the state of the parent table and the users role, they would have the option to click 'new' to create new records on the child table using the related list. When the 'new' button is clicked, it opens a new form for the child table with the 'parent table reference field' auto populated. Unfortunately, however the create ACL is triggered before the 'parent table reference field' is auto populated and therefore, the ACL is unable to determent what the parent for the new record would be (i.e. current.parent_field = null, when acl is triggered).

If you have a solution for my problem I would really appreciate it, and feel free to ask if you need further clarification about my issue.

Thank you.

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

another point i would like to mention here. if you are doing it on your custom table ( means both the table "parent" or "child" are custom table) then i believe you have one field that make a link between "parent" and "child". so in that case condition would be like 

ie: current.<field that reference to child table>.state == 4

if you are using in OOTB then ignore it.

 

adding one thread would also help you.

 

https://community.servicenow.com/community?id=community_question&sys_id=a5a88f21db5cdbc01dcaf3231f96...

View solution in original post

5 REPLIES 5

Harsh Vardhan
Giga Patron

current.parent.<field name>=null

can you just give a try

Hello Harshvardhan,

Thank you for the quick reply, wow, this works, current.parent.state returned the right value after I click the 'new' button.

What I noticed is when you load a record from the parent table, the related list also triggers the same create ACL check, and at that stage current.parent.state = "", which results to the create ACL being true on the related list, hence showing the 'new' UI Action button on the related list regardless of which user opens the parent record.  However, this is no longer an issue as although the new button would be always visibile, when the user clicks the 'new' button, the create ACL would run check again and is now able to properly detect the parent tables state and using that to the determine whether if the user has permission to create. 

If you have a solution for making it detectable on the related list on the parent table, that would be very helpful aswell.

Thank you very much,

 

 

i think this is just because you might have set the related list "with the form".

 

find_real_file.png

what is your exact business case here?

how about if you will hide the "new" button based on parent state value?

 

Once again thank you for the quick reply.

No, setting the Related List load from, "with the form" to "After Form Loads" or "On-demand" has the same results.

It was less a business case, and more a just UI related fix I am trying to do, where by I am attempting to hide the 'new' button to a user that doesnt have create permission.

Yes, I guess I will just have to add extra condition on the "New" button to check for the state.

 

Thank you very much once again.