Removing Field Values based on Access Groups

RapidIdentity Platform Documentation

Solution
Application
Content Type
Technical Documentation
Utilities & Services
ft:locale
en-US

Use mapping expressions to surgically remove org codes from user records when excluded by Access Group restrictions.

Studio Access Groups provide a way to restrict data rostered to a target application, but they work at the record level and don't surgically remove restricted values from multi-valued fields at the field level.

For example, when setting an Access Group to restrict data based on specific schools:

  • Only org records associated with selected schools are included in orgs output
  • Only user records associated with selected schools are included in users output
  • User records will still contain references to non-included schools in their orgs field

This can cause target applications to reject Studio output when validating org record references.

To surgically remove org codes from the orgs field on user records when an org is excluded by Access Group restriction, use this mapping expression on the user record orgs field mapping:

/* Remove any orgs from the array of orgs that are excluded by Access Groups */
function() {
  const orgs = SRC.org;
  var cleanOrgs = [];

  // Fetch Org Records Filtered by Access Groups
  const allowedOrgs = SRC.applyAccessGroups(SRC.listRecords("org"));

  if (allowedOrgs && allowedOrgs.length>0)

    for (var i = 0; i < allowedOrgs.length; i++) {

        for (var y = 0; y < orgs.length; y++) {
          if (orgs[y] == allowedOrgs[i].recordKey[0]) {
            cleanOrgs.push(orgs[y]);
          }
        }

    }

  return cleanOrgs;
}

When used on the orgs field in user mappings, only orgs specified by an Access Group are included in the orgs field:

Important:The SRC.applyAccessGroups method is time-consuming and will lengthen the duration of the mapping job.

For additional information on the SRC.applyAcccessGroups method and other Studio Expressions, see Studio Expressions documentation.