Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

Using an external .groovy file with custom validation for AD JSONs

richardc
New Contributor
New Contributor

Is it possible to improt an external groovy file with some useful functions etc in to Sav?

Example:

Based on 2 custom properties we would like to return a value.

Groovy:

def calcValue(val1, val2) {
 if (val1=='x' && val2 == 'y') {return 'x')

...

...

}

 

UpdateAccountJSON (AD):

${
Map updateAccountMap = new HashMap();
updateAccountMap.put("employeeType", SomeGroovy.calcValue(user.customproperty1, user.customproperty2));
jsonBuilder = new groovy.json.JsonBuilder(updateAccountMap);
return jsonBuilder.toString();
}

I know the syntax is not quite right, but hopefully you get the drift.

The reason for this is the logic inthe calcValue will be very complex and used in multiplle places, so doing it in every JSON would be maintence hell.

Thanks in advance.

 

Also would such customization be compatible with 2021/2022?  Would there be an alternative in those version?

1 REPLY 1

rushikeshvartak
All-Star
All-Star

As a part of stronger security framework for the application, you can no longer initialize objects, ie. using 'new' keyword to initialize a hashmap, list etc.

You would need to use the usual mapping format and use conditional logic via ternary operators or if-else.

You will get error as 

Error while Update operation for account-EURIEHWANG in AD - Template contains string which are not allowed \bnew\s+[a-zA-Z0-9_.]{1,}\s*\(

Reference:

https://forums.saviynt.com/t5/identity-governance/hashmap-error-in-ldap-connector-version-2021/m-p/9... 


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.