and more in a single search tool across platforms. Read the announcement here. |
07/20/2022 05:13 AM - edited 07/20/2022 05:20 AM
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?
07/20/2022 08:28 AM
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: