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

Pavankumar_1
Mega Patron

Hi @veena mudaliar ,

Try below script:

answer = (function transformEntry(source) {
    var startdate = new GlideDate();
    if (source.u_start_date) {
        var date = source.u_start_date.split(' ')[0]; //need space b/w source date and time
        return date;
    } else {
        return startdate;
    }
})(source);
If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

veenamudaliar_0-1667814898061.png

still not working start date is not coming

Hi @veena mudaliar ,

script is not same which I provided. on else return startdate not date.

If still not updating then that should be format issue if source and target formats are not same it will ignore.

Ex: source date=02/03/2022  and target start date - 02/03/2022 

if both are different formats it will not update then you need send the target format.

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

suvro
Mega Sage

return date; //in the last line

veenamudaliar_0-1667814898061.png

still not working start date is not coming in target table