Convert Local Datetime to JSON Format in Java Script

 


When we're passing local Datetime values to IFS REST calls we will need to convert format to JSON. Below I'll demonstrate a requirement where we used Workflow to trigger IFS REST API Request.

In here I'll get the current datetime in JavaScript and convert it.

We can get the Current Datetime in JavaScript like below:

var isysDate = new java.sql.Timestamp(new java.util.Date().getTime());
To set the value:
execution.setVariable('SysDate',isysDate);
Conversion to JSON format:

var event = new Date(isysDate ); var jsonDate = event.toJSON(); execution.setVariable('JsonDate',jsonDate);
 

I'm using above code like below in my example to get the values:


Workflow JS Part


Pass the values to REST API Call:




Post a Comment

0 Comments