We are delighted to share our new EIC Delivery Methodology for efficiently managing Saviynt Implementations and delivering quick time to value. CLICK HERE.

Compare dates in a REST connector for ServiceNow

KhaoulaD
New Contributor III
New Contributor III

Hello,

I'm trying to create account and push it into serviceNow. I need to compare the start date of the identity to the current date to take an action based on the result.

I have tried cases below but seems that when adding this condition, the payload is pushing the account with hardcode values into serviceNow as following: 

"active""${user.startdate < new Date() ? 'true' :",
 
The different cases i tried are as following:
  • \"active\":\"${(user?.startdate<(Calendar.getInstance().getTime()))?'true':'false'}\"
  • \"active\":\"${user.startdate < new Date() ? 'true' : 'false}
  • \"active\":\"${user.startdate.compareTo(new Date())==-1?'false':'true'}\"
     
    Could you please share any idea that works for you?
     
    Best Reagrds,
    Khaoula
4 REPLIES 4

pruthvi_t
Saviynt Employee
Saviynt Employee

Hi @KhaoulaD ,

Greetings.

We had a similar query earlier where current date was being compared with enddate as part of a REST json.

Below is the earlier post where we had responses with respect to the requirement. Please take a look at it and try the suggestions provided.

https://forums.saviynt.com/t5/identity-governance/current-date-comparison-in-rest-connector-update-a...

Thanks,


Regards,
Pruthvi

sk
All-Star
All-Star

@KhaoulaD : Can you try below?

\"active\":\"${(user?.startdate.format('dd-MM-yy)'<(Calendar.instance.format('dd-MM-yy')))?'true':'false'}\"


Regards,
Saathvik
If this reply answered your question, please Accept As Solution and give Kudos to help others facing similar issue.

KhaoulaD
New Contributor III
New Contributor III

Hello @sk,

I have tried your suggestion as following:

\"active\":\"${(user?.startdate.format('dd-MM-yy')<(Calendar.instance.format('dd-MM-yy')))?'true':'false'}\"

with the startdate = 12/12/2023 but the result returned is True. It it supposed to be false as 12/12/2023>28/11/2023

Could you please help on that?

Best Regards,

Khaoula DOUHI

KhaoulaD
New Contributor III
New Contributor III

Hello,

I have been able to sort it out.

The correct syntax to compare dates in Rest JSON is: 

\"active\"😕"${(user?.startdate.format('yyyy-MM-dd')<(Calendar.instance.format('yyyy-MM-dd')))?'true':'false'}\"
 
Best Regards,
Khaoula DOUHI