Click HERE to see how Saviynt Intelligence is transforming the industry. |
05/17/2024 05:14 AM - edited 05/17/2024 05:16 AM
Hello,
when we update an account, we need set its status to inactive if a user's last access date is earlier than 30 days. the user's customproperty33 (Just for example) has its last access date such as "20240416". How can I determine this date of this string is earlier than 30 days with one single line of code? and no new keyword to be used? looks the SimpleDateFormat with pattern "yyyyMMdd"" must be initialized with new keyword.
Is it possible to execute multiple javascript statements instead of single line of code in create/updateAccountJSON?
Solved! Go to Solution.
05/17/2024 05:58 AM
@alc Please find below sample:
${(user?.startdate.format('yyyy-MM-dd')<(Calendar.instance.format('yyyy-MM-dd')))?'true':'false'}
05/17/2024 06:13 AM
Hello Raghu, Thanks for your help!
the startdate and Calendar does not have format method to call. is this javascript API different from Java API call?
Thanks
05/17/2024 06:16 AM
@alc it will take current date format from Calendar Object .
use simple fomat object java
if (user?.startdate.format('yyyy-MM-dd') > new java.text.SimpleDateFormat('yyyy-MM-dd').format(new Date()))
05/17/2024 07:35 AM
Hello Raghu,
the "new" keyword is not allowed/recommended in Saviynt JSON setting.
05/17/2024 07:44 AM
try @alc
${(Date.parse('dd-MM-yyyy', user?.customproperty1) > Date.now()) ? user?.customproperty1 : Calendar.getInstance().format('dd-MM-yyyy')}
05/17/2024 07:09 AM
Option 1:
${Date.parse("dd-MM-yyyy", user.customproperty1)>(new Date())?user.customproperty1:(new Date().format("dd-MM-yyyy"));}
Option 2:
${Date.parse("dd-MM-yyyy", user.customproperty1)>(java.util.Calendar.instance.time)?user.customproperty1:(java.util.Calendar.instance.time.format("dd-MM-yyyy"));}
05/17/2024 07:36 AM
Hello Rushikesh,
The
java.util.Calendar.instance.time is not visible, it is not public field to access directly. Also I need compare with the date of 30 days ago, not today.
05/17/2024 07:46 AM
Please share conditions you tried as per your use case
05/17/2024 07:55 AM
Hello Rushikesh,
This is what I have set:
${if(user?.customproperty1 != null && user.customproperty1.length() == 10 && new java.text.SimpleDateFormat('yyyy-MM-dd').parse(user.customproperty1).getTime() <= (Calendar.getInstance().getTimeInMillis() - (30*86400000))){'Invalid'}else{'Valid'}}
But the code reviewer said I cannot use new keyword to initialize java.text.SimpleDateFormat object.
Please help. the idea is to check if the specified user customproperty value is within 30 days of today or earlier than 30 days of today.
05/19/2024 10:46 AM
${if(user?.customproperty1 != null && user.customproperty1.length() == 10 && java.time.LocalDate.parse(user.customproperty1).isBefore(java.time.LocalDate.now().minusDays(30))){'Invalid'}else{'Valid'}}