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

Brian
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.

 

2 REPLIES 2

rushikeshvartak
All-Star
All-Star

Whats date format from target 


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

Brian
New Contributor II
New Contributor II

The date format in the response is:

2017-06-16T15:10:11Z
 
Example:
<CREATION_DATE>2018-01-19T17:37:24Z</CREATION_DATE>
<LAST_LOGIN_DATE>2024-02-15T16:03:14Z</LAST_LOGIN_DATE>
 
We are only having issues with LAST_LOGIN_DATE however because CREATION_DATE is never null or empty.