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

REST connection ImportAccountEntJSON - Setting LASTLOGONDATE gives error when returning null

New Contributor II
New Contributor II

Hello, I'm on version 23.12 and running into an issue when importing accounts who do not have a LASTLOGONDATE.  Each time I try to get it to return null, it is trying to insert the string literal 'null' into the database, causing the error: 


Data truncation: Incorrect datetime value: 'null' for column 'LASTLOGONDATE' at row 1


I am inserting the Datetime as ~#~char instead of ~#~date. When I used ~#~date I've tried returning a Date object and a String object. Each time, there are no errors but also no dates show in any accounts.  Using ~#~char works fine for those entries that do have dates.

I've performed many variations, but here are my recent attempts to get null written instead of 'null':


# Attempt 1:
"lastlogondate": "#CONST#${if(response.LAST_LOGIN_DATE){return Date.parse(\"yyyy-MM-dd'T'HH:mm:ss'Z'\",response.LAST_LOGIN_DATE).format('yyyy-MM-dd HH:mm:ss');}else{return null};}~#~char"

# Attempt 2:
"lastlogondate": "#CONST#${if(response.LAST_LOGIN_DATE){return Date.parse(\"yyyy-MM-dd'T'HH:mm:ss'Z'\",response.LAST_LOGIN_DATE).format('yyyy-MM-dd HH:mm:ss');}else{return};}~#~char"

# Attempt 3:
"lastlogondate": "#CONST#${String dateString; if(response.LAST_LOGIN_DATE){dateString= Date.parse(\"yyyy-MM-dd'T'HH:mm:ss'Z'\",response.LAST_LOGIN_DATE).format('yyyy-MM-dd HH:mm:ss');};return dateString;}~#~char"


Any help is appreciated.




Whats date format from target 

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

New Contributor II
New Contributor II

The date format in the response is:

We are only having issues with LAST_LOGIN_DATE however because CREATION_DATE is never null or empty.