Saviynt unveils its cutting-edge Intelligence Suite products to revolutionize Identity Security!
Click HERE to see how Saviynt Intelligence is transforming the industry.
Saviynt Copilot Icon

Use current date and date comparison in AD connector

snauni
New Contributor III
New Contributor III

Hello All,

We have a requirements within an AD connector update account JSON where Saviynt should only pass the title attribute on a user's start date (as the user can be onboarded before their start date as well).

We wanted to check if user's start date is greater than or equal to current date, then only pass the title attribute, otherwise pass empty string. Something like below:

"title":"${if(u.customproperty10 >= Date()) {user.title} else {''}}"

Do you have some sample working current date attributes / functions we can use within the connection? We might also need to have the same format for both the dates so that they can be compared.

8 REPLIES 8

Raghu
All-Star
All-Star

@snauni  try below

 


  "title": "${new Date(u.customproperty10) >= new Date() ? user.title : ''}"


Thanks,
Raghu
If this reply answered your question, Please Accept As Solution and hit Kudos.

snauni
New Contributor III
New Contributor III

This did not work, we are getting the conversion error: Error Updating the Account from AD - Error in attribute conversion operation, data 0, v4f7c

rushikeshvartak
All-Star
All-Star


"title": "${(new Date()).compareTo(new SimpleDateFormat('yyyy-MM-dd').parse(user.customproperty10)) >= 0 ? user.title : ''}"


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

This did not work, we are getting the error - Error Updating the Account from AD - Template contains string which are not allowed \bnew\s+[a-zA-Z0-9_.]{1,}\s*\(

"title": "${if (new Date().toISOString().split('T')[0] >= user.customproperty10) {user.title} else {''}}"


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

This did not work as expected. Saviynt is passing the entire condition as a string to AD. Title was passed as "${if (new Date().toISOString().split('T')[0] >= user.customproperty10) {user.title} else {''}}".

 "title": "${groovy.lang.GroovyShell.evaluate('new Date().format("yyyy-MM-dd") >= user.customproperty10 ? user.title : ""')}",


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

This did not work. It looks like we cannot pass the variable groovy. 

Thanks for the help. We were able to make it work using the below syntax:

"title":"${if(user.customproperty10 <= (Calendar.getInstance().getTime().format('yyyy-MM-dd'))) {user.title} else {''}}"