Sidebar

Removing invalid emails in pid-13[1].4

0 votes
467 views
asked Dec 30, 2016 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 */
answered Dec 30, 2016 by gary-t-8719 (14,860 points)
selected Dec 30, 2016 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', '');
}
answered Dec 30, 2016 by gary-t-8719 (14,860 points)
edited Dec 30, 2016 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);
answered Feb 23, 2017 by chris-m-8014 (760 points)
...