Start a new topic

Example for editing ACL on a presave collection hook

Hi. I would like to add a reader and a writer group to an entity, on presave

Can you please show me a business logic code example for how we can intercept the save and add the groups to the acl (so they are added when the save is actioned)

I can't an example in the docs nor anything in the forums (except for advice that it is possible)


Hey AB, We'd love to create a sample like this, it's just a matter of having the time to do so. I'll pitch it to the team and see if we can get someone to take a deeper dive on a sample. In the meantime, perhaps some other community members have some examples of what they've done to handle similar use cases.
Even a hint on the code would be helpful! E.g. how do we access the _acl value and then overwrite it? (I can then do the actual code)
Hi @"A B"‌

Here's a very simple sample that should get you moving in the right direction

function onPreSave(request, response, modules) {

var acl = request.body._acl;

if(!acl.groups) {

acl.groups = {}


if(!acl.groups.r) {

acl.r = [];


if(!acl.groups.w) {

acl.w = []


acl.r.push 'my_group'

acl.w.push 'my_group'



For reference, the documentation about the structure of ACLs is [here]( and the documentation for the Request object is [here](
Login or Signup to post a comment