Email validation in on before script in transform map

Mr_Avinash
Kilo Expert

I need to validate the email. im trying to write on before script in a transform to validate email field and my target table is sys_user.In the source table the field is u_email.

1 ACCEPTED SOLUTION

You can use the email type field or variable which will automatically validate the email address 

or 

try this script :

var email = source.u_email;


if (!email || email.trim().length <= 0)


return true;


var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;


if (!re.test(email))

{

ignore =true;
}

else

{
ignore = false;
}

or you can follow this link :

https://community.servicenow.com/community?id=community_question&sys_id=83b88a49dbb7eb80feb1a851ca96...

mark my answer correct and helpful if it helps you !

regards,

apeksha

View solution in original post

8 REPLIES 8

use the script in on before transform map script , select the source(your source table) and target table(sys_user) .

map the fields with mapping assist or auto map matching fields. 

You can use the email type field or variable which will automatically validate the email address 

or 

try this script :

var email = source.u_email;


if (!email || email.trim().length <= 0)


return true;


var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;


if (!re.test(email))

{

ignore =true;
}

else

{
ignore = false;
}

or you can follow this link :

https://community.servicenow.com/community?id=community_question&sys_id=83b88a49dbb7eb80feb1a851ca96...

mark my answer correct and helpful if it helps you !

regards,

apeksha

in transform map select your source and target table ,map the fields using auto map matching fields or mapping assist.

and then use the above script in transform map script(on before)

Apeksha Joshi
Kilo Guru

You can use the email type field or variable which will automatically validate the email address 

or you can follow this link :

https://community.servicenow.com/community?id=community_question&sys_id=83b88a49dbb7eb80feb1a851ca96...

mark my answer correct and helpful if it helps you !

regards,

apeksha