We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Convert and populate date of String type to the Date type field using field map script(transform map

kamadi lokeshra
Tera Contributor
 
1 ACCEPTED SOLUTION

Hi @kamadi lokeshra 

 

Hope You Source string field value having specific format.

Create a On before  transform map script and add following snippet  (correct that date format as you want  as per your existing configuration)

 

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

var dtObj = new GlideDate();
dtObj.setDisplayValue(source.u_actual_date, "dd-MMM-yyyy");
var dtVar = dtObj.getByFormat("MM-dd-yyyy");
target.new_joining= dtVar;

})(source, map, log, target);

 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

View solution in original post

4 REPLIES 4

Tanushree Maiti
Tera Patron

Hi @kamadi lokeshra 

 

Here is the script:

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

var dtObj = new GlideDate();
dtObj.setDisplayValue(source.u_actual_date, "dd-MMM-yyyy");
var dtVar = dtObj.getByFormat("MM-dd-yyyy");
target.actual_date= dtVar;

})(source, map, log, target);

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

Hi @Tanushree Maiti ,

It is not working as expected. 
My source field is g_hiredate which is of string type and target field is new_joining which is of date type.

Hi @kamadi lokeshra 

 

Hope You Source string field value having specific format.

Create a On before  transform map script and add following snippet  (correct that date format as you want  as per your existing configuration)

 

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

var dtObj = new GlideDate();
dtObj.setDisplayValue(source.u_actual_date, "dd-MMM-yyyy");
var dtVar = dtObj.getByFormat("MM-dd-yyyy");
target.new_joining= dtVar;

})(source, map, log, target);

 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

Hi @Tanushree Maiti ,
It is working as expected after making the date format(as source date format) under the source field.
Thank you for your solution and for the quick response.