and more in a single search tool across platforms. Read the announcement here. |
02/28/2024 04:26 AM
Hello All,
Could you please help with the below?
I need to compare the date stored in user's cp1 to the current date and take an action based on the result in the CreateAccountJSON.
Scenario-
I have stored a date in user cp1 in the format dd-mm-yyyy.
The condition is if the user cp1 date value is greater than the current date then I need to pass user.cp1 else current date in the format dd-mm-yyyy.
I've tried with the below syntax.
1. ${(Date.parse(user?.customproperty1).getTime()>(Calendar.instance.format('dd-MM-yyyy')))?'a':'b'} 2. ${(Date.parse('dd-MM-yyyy',user?.customproperty1).getTime()>(Calendar.instance.format('dd-MM-yyyy')))?'a':'b'}
Any help with the syntax is appreciated.
Solved! Go to Solution.
02/28/2024 05:31 AM
@Vedanth-BK can you try like below format , may be help full
"${(user?.customproperty1.format('yyyy-MM-dd')<(Calendar.instance.format('yyyy-MM-dd')))?'true':'false'}
02/29/2024 12:06 AM
Hi @CR
Thanks for responding,
the cp1 is considered as a string i need to parse it and then compare.
02/29/2024 12:21 AM
\"active\"😕"${new java.text.SimpleDateFormat('yyyy-MM-dd').format(user?.customproperty1)<(Calendar.instance.format('yyyy-MM-dd')))?'true':'false'}\
02/29/2024 12:32 AM
tried the above syntax-Failed
Up to best of my knowledge, the keyword new cannot be utilized.
02/29/2024 12:36 AM - edited 02/29/2024 12:45 AM
@Vedanth-BK
You may try with,
"httpParams": "{\"IsFrozen\": \"${(user?.enddate<=(Calendar.getInstance().getTime()))?'true':'false'}\"}"
Thanks,
02/29/2024 12:44 AM - edited 02/29/2024 12:45 AM
Hello @sudeshjaiswal
attaching a log snippet and the httpParams above .Please let me know if iam missing anything.
02/29/2024 01:14 AM - edited 02/29/2024 01:21 AM
Hello @Vedanth-BK,
Can you please try with the below in the createaccountjson.
"${(Date.parse('dd-MM-yyyy',user?.customproperty1).getTime()<=(Calendar.getInstance().getTime()))?'true':'false'}\"
OR
"${(Date.parse('dd-MM-yyyy', user?.customproperty1).getTime() >= Calendar.getInstance().getTime())
? user.customproperty1
: Calendar.getInstance().format('dd-MM-yyyy')
}"
Thanks.
02/29/2024 03:34 AM
Hi Sudesh
both syntaxes failed to parse.
02/29/2024 05:11 AM
Hello @Vedanth-BK,
Can you try the below sample :
${(Date.parse('dd-MM-yyyy', user?.customproperty1).getTime() > Date.now()) ? user?.customproperty1 : Calendar.getInstance().format('dd-MM-yyyy')}
Thanks.
03/03/2024 09:30 PM
Hello @Vedanth-BK,
Can you please share the screenshot of the data stored in CP1.
Thanks.
03/06/2024 11:15 PM
Try these -
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"));}
03/07/2024 03:00 AM
Iam able to achieve my use case thank you @vivekmohanty_pm
thanks for inputs @sudeshjaiswal