Transformation scripts
Map an inbound synchronization row onto an OpenIAM user, group or role — the base classes, the return signals, the caches, and an annotated shipped example.
Applies to: OpenIAM 2026.8.1
A transformation script maps one inbound row from a source system onto one OpenIAM object.
Start here if you are new to OpenIAM scripting. It does one thing, its inputs are simple, and its result is easy to see.
What this builds, and how long it takes
You get
A script that turns rows from a source feed into OpenIAM users, groups or roles
Time
An hour for a first script, including a test synchronization
You need
A deployment, a synchronization configuration, and a source with a few rows in it
Reversible
Yes — increment the version and the previous script is still there
Before you start
Set up your environment, so the script compiles before you deploy it.
How scripting works, for the conventions.
A source you can run against with a handful of rows. Not the full feed.
Build it
1. Understand what the script receives
rowObj is the inbound row. pUser is the object you populate. The return value is a signal telling synchronization what to do with this row, not a status code:
SKIP
-1
Ignore this row entirely
NO_DELETE
0
Process normally. The usual return
DELETE
1
Delete the matched object
DISABLE
2
Disable it
ENABLE
3
Enable it
EXCEPTION
4
Treat as an error
INITIATE_NEW_HIRE_WORKFLOW
5
Start the new-hire workflow
INITIATE_EDIT_USER_WORKFLOW
6
Start the edit-user workflow
They are inherited, so write NO_DELETE, not TransformScript.NO_DELETE.
2. Pick the base class
AbstractUserTransformScript
ProvisionUser
Users
AbstractGroupTransformScript
Group
Groups
AbstractRoleTransformScript
Role
Roles
AbstractOrganizationTransformScript
Organization
Organizations
AbstractResourceTransformationScript
Resource
Resources
All extend AbstractTransformScript<T>, which is where the shared behavior lives.
The user case takes a ProvisionUser, not a User. That catches people out, because most of the rest of the API deals in User.
3. Write it
?.value, not .value. A column absent from the row gives null from the map, and ?. stops that becoming a NullPointerException that fails the run.
4. Use what the base class gives you
AbstractTransformScript provides more than the method signature:
isNewUser
true when this row creates an object rather than updating one. The most useful flag on the class
log
A logger. Do not declare your own
context
The Spring ApplicationContext
rolesByName, groupsByName, resourcesByName, usersByLogin, organizationByName, managedSystemByName, resourceTypeByName
Name-keyed caches, populated for you
rolesById, groupsById, resourcesById
The same, keyed by id
metadataTypesByGroupingAndName
Metadata types by grouping and name
Use the caches. Looking the same role up for every row of a fifty-thousand-row feed is what makes a synchronization slow.
5. Read a shipped example
From conf/iamscripts/sync/role/csv/CSVRoleSampleTransformationScript_1.0.groovy, abridged:
Four things worth taking from it:
if (isNewUser) { role.id = null }— clearing the id on creation lets the platform assign one. Carrying an id from a previous row is a common way to update the wrong object.The work is in a private method.
executehandles the outcome;populateObjectdoes the mapping. Worth copying — it keeps error handling in one place.It catches and returns a signal rather than letting the exception escape. An uncaught exception fails the row, and depending on configuration can fail the run.
It reaches a service directly to build a relationship the row implies. Transformation is not limited to setting fields.
6. Deploy it
Webconsole → Administration → Groovy Manager.
Expand the folder for your synchronization configuration under
sync/.New Script, paste, Save. It compiles on save; a compilation error appears with its stack trace.
Reference the script by name in the synchronization configuration.
Verify it
Run the synchronization against a small source first.
The script was called
Your log output, or a println, in the service log
Objects were created or updated
The console, on the objects the rows describe
Rows were skipped
The synchronization result — a processed count lower than the source row count
Then run it a second time against the same source. The first run tests creation; the second tests the update path, and they fail differently.
If it goes wrong
Compilation fails on save with unable to resolve class
An import is wrong, or the class is not on the platform's classpath
Check the import. Compile locally first — Set up your environment
NullPointerException on a column
The column is absent from that row
Use ?.value, and decide what an absent column should mean
Every row is skipped
execute is returning SKIP, usually from the catch
Log the exception in the catch block. It is being swallowed
Objects are created but fields are empty
Column names do not match the source
Log rowObj.columnMap.keySet() once and compare
Updates create duplicates
The id is cleared on update, or matching is not finding the existing object
Guard the id reset with isNewUser, and check the matching configuration
The run is very slow
Per-row lookups instead of the caches
Use rolesByName and the other caches
What this procedure does not cover
Configuring the synchronization itself — the source connection, the schedule and the matching rules are the Administration Guide's subject. Deciding which source is authoritative for which attribute is a design question, and belongs in the Solution Architecture and Design Guide.
Related
Validation and attribute scripts — what runs before this
Last updated
Was this helpful?