Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

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?

10 REPLIES 10

CR
Regular Contributor III
Regular Contributor III

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

rushikeshvartak
All-Star
All-Star

"colsToPropsMap": {

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

Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

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 you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

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 you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

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 you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

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.