The CreatorCon Call for Content is officially open! Get started here.

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

U_Viswa
Mega Sage

Hi Veena,

 

Can you try below script. It is working for me

if(source.u_start_date){
	var gdt=new GlideDateTime(source.u_start_date);	
	target.u_start_date=gdt.getDate();
}

 

Thanks

Viswa

 

need a script for end date field validation 

end date should greater than start date if it not greater null that value in target

Hi,

Write below code in End Date source script.

if(source.u_end_date){
		var gdt1=new GlideDateTime(source.u_end_date);
		var edt=gdt1.getDate();
	}

	if(source.u_start_date){
		var gdt2=new GlideDateTime(source.u_start_date);
		var udt=gdt2.getDate();
	}
	if(edt < udt){  //End date is less than Start date
		target.u_end_date='';
	}
	else{
		target.u_end_date=edt;
	}

  Thanks

Viswa

 

Pavankumar_1
Mega Patron

Hi @veena mudaliar ,

If your issue got resolved close the question by Accepting solution and hit thumb icon.
If not reply and share details.

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

Pavankumar_1
Mega Patron

Hi @veena mudaliar ,

If your issue got resolved close the question by Accepting solution and hit thumb icon.
If not reply and share details will try to resolve your issue.

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar