Skip to content

Commit b6383f7

Browse files
emailFormatValidator can be used while importing data and conform to a standard email format. (#1438)
1 parent 9b489c5 commit b6383f7

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
(function checkEmail(source, target, map, log, isUpdate) {
2+
// Replace with your source email field
3+
var email = source.u_email;
4+
if (email) {
5+
email = email.trim().toLowerCase();
6+
//Regular Expression to validate email pattern
7+
var emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
8+
if (emailPattern.test(email)) {
9+
// Replace with your target email field
10+
target.email = email;
11+
} else {
12+
log.info('Invalid email format for ' + email);
13+
}
14+
}
15+
})(source, target, map, log, isUpdate);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The purpose of this script is to validate email addresses during a data import in ServiceNow. It ensures that the email addresses conform to a standard format (i.e., are valid email addresses), converts them to lowercase, trims any extra spaces, and logs invalid email addresses for review or further action.

0 commit comments

Comments
 (0)