Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Transform map scripting date validation

veena mudaliar
Tera Contributor

veenamudaliar_0-1667809994269.png

in source table start date type is date/time and in target table start date type is only date now when i load the date with transform map excel sheet in excel if i put 02/03/2022 i target it coming as 01/03/2022 beacuase of time i need to ignore the time in script and just need to take date above script is written its not working

14 REPLIES 14

RaghavSh
Mega Patron

I think there is a code error as in your else part of script you need to set answer as answer = dateTime[0];

You are setting answer as split and not the 1st element after split.

 

it should be var date = u_source_start_date.split('');

answer = date[0];


Raghav
MVP 2023
LinkedIn

veenamudaliar_1-1667815124252.png

still not working start date is not coming

Hi Veena ,

Comment the line: answer = '';

var startDate = new GlideDate();

if(source.u_start_date =''){

gs.log('Enter);

gs.log("Source Date :"  +source.u_start_date);

answer = startDate ; if this doesnt work 

try this as well

target.backened_name of the target _start date = startDate;

gs.log("Target Date :"  +target.start_date); // Check the your target field name;

}

else {

var date = [];

// get the value of the source date in one variable.

var sourcedate = source.u_startdate;

date = sourcedate.split(' ');

check what value are you getting using gs.log('Answer: +answer + 'Date :' + date[0] + 'Source Date: '+sourcedate ) ;

answer = date[0]; OR target.source_date = date[0];

 

 

}

 

MD AQUIB KHAN
Giga Guru

Hi , 

Try using the Code

/* GlideDateTime */
/* Get the current time */
 
var gdt = new GlideDateTime(); 
var date = gdt.getDate();
var time = gdt.getTime();
gs.print("date: " + date);
gs.print("time: " + time);
gs.print("gs.nowDateTime(): " + gs.nowDateTime());