Acls not populating for Facility type


#1

I’m looking to create Acl’s by Facility - Users are assigned to Facilities so that they can only view those to which they’re assigned.

I’ve set up Facility_AclPrivileges.json:

{
  "type": "[AclPrivilege]",
  "value": [
    {
      "typeName": "Facility",
      "canUpdate": "true",
      "canRemove": "true",
      "canModifyAcl": "true",
      "acl": {
        "expr": "userIntersections.user"
      },
      "id": "Facility_AclPrivilege",
      "name": "Facility AclPrivilege"
    }
  ]
}

EnableAclPrivilege.json:

{
  "type": "[EnableAclPrivilege]",
  "value": [
    {
      "enabled": true,
      "id": "Facility_acl_controlled",
      "name": "Facility Acl Controlled",
      "typeName": "Facility"
    },
    {
      "enabled": true,
      "id": "FixedAsset_acl_controlled",
      "name": "FixedAsset Acl Controlled",
      "typeName": "FixedAsset"
    }
  ]
}

And I set up a type called UserToFacilities, which holds the relationship information between a User and the facilities they belong to.

When I run the following code and then fetch fac-1 again, I only see one entry in the acl array which is for BA:

var filename = 'test_FacilityAcls';
var context, user, facilities, facilityFilter, userToFacility,
    contextUsername = c3Context().username,
    impersonationGroup = 'MyEndUserGroup';

context = TestApi.createContext(filename);

facilities = TestApi.createBatchEntity(context, 'Facility', [{ id: 'fac-1' }, { id: 'fac-2' }]);
user = TestApi.createImpersonationUser(context, impersonationGroup);

userToFacility = TestApi.createEntity(context, 'UserToFacilities', {
    user: user,
    facilities: [{ id: 'fac-1' }]
});

Facility.populateAcl([Facility.get('fac-1')]);
Facility.refreshAcls({ async: false });

Is there something I’m missing? I reviewed this setup with @garnaiz the other day and we weren’t able to find anything wrong here. This is on c3server 7.8.0.4758-1