1.2k questions

1.4k answers

361 comments

339 users

Categories

Sidebar
0 votes
696 views
by jeremy-c-6009 (300 points)
Currently CPS does not apply a policy to validate email addresses, which allows many staff to enter 'none', 'refused' or other notes in this field.

We would like to blank out only the email field in the outgoing files if it does not contain a @ in the text of the field.

|^^^None~(773) 999-9999^^CP|

The email appears to be in PID-13[1].4, so need to ensure that we protect the phone number in PID-13[2].1

Ultimately to take the invalid email (not containing @ in the field), 'None' in example above, and removing it to be blank. while preserving the Mobile Phone folowing if it exists.

3 Answers

0 votes
 
Best answer
//Checks for the existence of both a @ and a dot (.)
/*jshint regexp: false */
if (!/.+@.+\..+/ig.test(message.getNode('PID-13[1].4'))) {
   message.setNode('PID-13[1].4', '');
}
/*jshint regexp: true */
by gary-t-8719 (15.1k points)
selected by gary-t-8719
0 votes
//just checks for the @ symbol

if (StringUtils.containsNone(message.getNode('PID-13[1].4'), '@')) {
   message.setNode('PID-13[1].4', '');
}
by gary-t-8719 (15.1k points)
edited by gary-t-8719
0 votes
I have also used this code to remove 2 specific bad email addresses that are frequently input at my location.

 

var value = message.getNode("PID-13.4");
value = value.replaceAll('(?i)NONE@EMAIL.COM', '');
message.setNode("PID-13.4", value);

value = message.getNode("PID-13.4");
value = value.replaceAll('(?i)PT DECLINED', '');
message.setNode("PID-13.4", value);
by chris-m-8014 (760 points)
...