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

Converting Date Format in Rest Connector Account Import JSON

Wes
New Contributor III
New Contributor III

Hello!

I am attempting to convert the incoming StartDate and EndDate dates (mapped to ValidFrom and ValidThrough, respectfully) in the ImportAccountEntJSON. We are reading in the dates as: 

Wes_0-1710355472821.png

I have tried setting the attribute "dateFormat" (inside of "globalSettings") to:

"globalSettings": {
      "dateFormat": "yyyy-MM-dd'T'HH:mm:ss'+'hh:mm"
}

and set my date attributes and values to:

"colsToPropsMap": {

          "validfrom": "StartDate~#~date",
          "validthrough": "EndDate~#~date"
}
 
I got the idea to do this from this post.
 
The logs indicate that the StartDate and EndDate values are unparsable: Wes_1-1710356151657.png

Is a date conversion possible in this way?

18 REPLIES 18

Raghu
All-Star
All-Star

you can try like below format

${new java.text.SimpleDateFormat('MM-dd-yyyy').format(user.startdate)}


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

Wes
New Contributor III
New Contributor III

Hi Raghu!

Thank you for your response!

Where would this go in the ImportAccountEntJSON? StartDate and EndDate are coming from an external application, so those values wouldn't be in the user table.

 

Thank you,

- Wes

Sreejith
New Contributor III
New Contributor III

Hi @Raghu  may i know whether it will work for a customproperty that pass enddate(string) : 20240517 from HCM data. if yes can you provide the json for create account AD taks.

I mean how to convert CP39 to account expiry in AD on below json.

"accountExpires": "${if((user.employeeType.equals('Contractor'))&(user?.customproperty39!=null)){10000*(user?.customproperty39.getTime()+11644473600000+18400000)} else {'0'}}",

Above just supporting in import json of rest.

prefer creating new thread for your ask


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

rushikeshvartak
All-Star
All-Star

"colsToPropsMap": {

          "validfrom": "StartDate~#~datetime",
          "validthrough": "EndDate~#~datetime"
}

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

Wes
New Contributor III
New Contributor III

Hi Rushikesh,

Unfortunately no luck here, I don't think Saviynt was recognizing "datetime" as a data type.

Thank you,

- Wes

Use const ${Calendar.getInstance().getTime().format('yyyyMMddHHmmss')}Z function


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

Wes
New Contributor III
New Contributor III

This doesn't seem to work unfortunately. When I try to put any sort of Groovy code or function in the contents of the date conversion value, it either fails to import that value or it spits out exactly what I have written in.

 

For example, I tried this earlier:

 

"customproperty20": "#CONST#${SimpleDateFormat simpleformat = new SimpleDateFormat(\"MM-dd-yyyy HH:mm:ss\"); return simpleformat.format(StartDate)}~#~char"
 
I'm using customproperty20 so I can see better what is getting passed.
 
What ends up happening is that the value of customproperty20 will end up being this:
#CONST#${SimpleDateFormat simpleformat = new SimpleDateFormat(\"MM-dd-yyyy HH:mm:ss\"); return simpleformat.format(StartDate)}

Can you confirm saviynt version. As above logic works for us

rushikeshvartak_0-1711071984257.png

 


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

Wes
New Contributor III
New Contributor III

So this does look to work, but it is populating the current time and not imported time unfortunately (I tested this in a customproperty.

I tried populating the validfrom/validthrough attributes by using this to see what would happen and it appears that they were not populated (even after I changed the datatype to "date")

try 

millisec

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

Wes
New Contributor III
New Contributor III

It took a while, but I figured out something I was doing previously works, I just inputted it slightly different now. All I had to add was this:

  "globalSettings": {
    "dateFormat": "yyyy-MM-dd'T'HH:mm:ss"
  }
 
Initially, my format was incorrect, which I think was causing the issue.
 

jralexander137
Regular Contributor
Regular Contributor

@Wes Do you mind sharing the full config with this added? I am having a similar problem.

Wes
New Contributor III
New Contributor III

Of course!

jralexander137
Regular Contributor
Regular Contributor

Thanks. Is the global setting date format you have corresponding to the format in the downstream system or the format you want to store it in in saviynt? I am trying to use the OOTB DUO connector but their config provided doesn't work for last_login which they have coded as a datemillis type. The value returned from DUO is a unix timestamp so I would have expected that to work with datemillis.

The DUO connector is basically an obsfucated REST connector so I was hoping the accountAttributeMapping json config would work similarly to a rest connection AccountEntImportJSON config.

Wes
New Contributor III
New Contributor III

The date format in the global setting would be corresponding to the downstream system format for the import. The connected application uses ISO 8601 time, so that is what I set it as here (minus the timezone 'Z' bit).

jralexander137
Regular Contributor
Regular Contributor

I see, corresponds to downstream system. So I would need to figure out the format for a unix timestamp since the value doesnt come across in an actual datetime format.