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

syntax for string validation for Dynamic Attributes used in Service Account Name Rule

AS
New Contributor II
New Contributor II

Hi @ all!

version is: 2021.0

The AccountNameRule is set the following:

${Attribute1}_${Attribute2.substring(1,10)}###INCREMENTINDEX###

Backround is:

- Attribut2,  if press "generate" shall be shortened, cause account-id should be not longer as "x"-chars in summary

Effect using .substring is, that u have to enter min 10 chars in the attribute field, otherwise substring can't  count. so far clear.

What i'm looking for in the acc name rule is something like a syntax for "left" for attribute2 in the rule. to reduce up to 10 chars from the left. something like ${Attribute2.left...and then?!} (if its possible at all to use "left" or "len", "length" or .. ...) 

Other option could be to reduce the possible input for attribute2 with regex to max. 10 chars in the template of the request. The thing is, it's from my point of view not comfortable for users, cause regex comes up with the error, if u submit, not if you put the data in. There might be some validation possibilities in the request template or in the dynamic attribute itself, kind of refresh, during the input by a user, but i didn't figured it out so far. And it's not possible, or it is?!, to define a qualified message for users, if regex runs into an error. 

I would be nice, if someone has an hint for my topic.

Best regards!

 

8 REPLIES 8

rushikeshvartak
All-Star
All-Star

Config :

rushikeshvartak_1-1652377665721.png

 

 

ARS :

rushikeshvartak_0-1652377641336.png

 


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

AS
New Contributor II
New Contributor II

pardon, this was not the question

amit_krishnajit
Saviynt Employee
Saviynt Employee

You may want to use the attribute in the following way in the rule:

${attr1?.length() > 10 ? attr1?.substring(0,10) : attr1}

This will take the full attribute value if the length is less than or equal to 10, otherwise will take only 10 characters. 

Thanks,
Amit

AS
New Contributor II
New Contributor II

Hi Amit,

thanks a lot, that works.

I have two questions.

Is there somewhere a documentation for the systematic behind syntax and possibilities. In a way with examples and declarations, what can be used, why and how?! 

And, is it possible the use "replace substring" for the whole account generation, if users using in attr1 "blanks", this should be replaced with "_"?!

Thanks a lot!

 

 

These are generic Groovy expressions, so this is not something specific to Saviynt only. The Groovy expressions follow similar syntax as Java, hence based on the object, their methods can be invoked. 

e.g., here attr1 is a String type of object, so methods like length, substring, replace, etc. can be used. 

I recommend validating the Groovy expressions in an online IDE(e.g., Online Groovy Compiler - Online Groovy Editor - Run Groovy Online - Online Groovy Runner (jdoodle.co...) before using in Saviynt to get rid of syntactical errors. 

For the replace method, you may use something like ${attr1.replaceAll(' ','_')}

Thanks,
Amit

AS
New Contributor II
New Contributor II

Okay, thanks, I got it!

The whole works like this:

${Attribute1}_${Attribute2?.length() > 10 ? Attribute2.replaceAll(' ','_')?.substring(0,10) : Attribute2.replaceAll(' ','_')}###INCREMENTINDEX###

Thanks!!!!

AshishDas
Regular Contributor II
Regular Contributor II

Hi,

Could you tell me what does ###INCREMENTINDEX### do? Are you using Advanced Query? Can we have Increment Index in advanced query

Service account just have advance query 


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