
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 02:49 PM
ver. Tokyo
This is just a random question which may or may not belong here. I was wondering if anyone has thought of using AI for field validation? For example, I'm working with a client that wants a list of every field {text fields, etc.} that could possibly accept PII, PHI data. One idea is that a set of business rules be built out which would be used to monitor various text fields and prevent the entry of SSN's and other PII/PHI.
My question is basically if there's any AI enabled way to do some type of field validation to search for PII/PHI?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 11:26 PM
Hi @ericgilmore ,
I trust you are doing great.
To achieve field validation for PII/PHI data, we can leverage ServiceNow's Business Rules and Regular Expressions. Here's a step-by-step approach:
Define a list of text fields that need to be monitored for PII/PHI data entry.
Create a Business Rule in ServiceNow to run on the table where these text fields exist. This rule should trigger on the 'before' or 'after' insert or update events, depending on your specific requirements.
In the Business Rule script, implement a regular expression pattern matching to search for PII/PHI data. Regular expressions are powerful tools for pattern matching, and they can help identify specific patterns like Social Security Numbers (SSNs) or other PII/PHI formats.
Here's an example of a regular expression that matches SSNs: /(^\d{3}-\d{2}-\d{4}$)|(^\d{9}$)/
Within the Business Rule script, retrieve the field values from the record being inserted or updated. Apply the regular expression pattern matching on these values to identify any PII/PHI data.
If a match is found, you can take appropriate actions, such as displaying an error message to the user, preventing the record from being saved, or triggering a workflow/notification to alert the necessary stakeholders.
Here's a sample code snippet in JavaScript, which can be used within the Business Rule:
(function executeRule(current, previous /*, g*/) {
var fieldValues = [current.field1, current.field2, current.field3]; // Specify the text fields to monitor
var regex = /(^\d{3}-\d{2}-\d{4}$)|(^\d{9}$)/; // Regular expression for SSN matching
for (var i = 0; i < fieldValues.length; i++) {
if (regex.test(fieldValues[i])) {
current.setAbortAction(true); // Prevent record from being saved
gs.addErrorMessage('PII/PHI data is not allowed in the field: ' + fieldValues[i]);
break;
}
}
})(current, previous /*, g*/);
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 08:19 PM
Hi @ericgilmore ,
In ServiceNow as of now we do not have feasibilty to use AI for field validation unfortunately.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 11:26 PM
Hi @ericgilmore ,
I trust you are doing great.
To achieve field validation for PII/PHI data, we can leverage ServiceNow's Business Rules and Regular Expressions. Here's a step-by-step approach:
Define a list of text fields that need to be monitored for PII/PHI data entry.
Create a Business Rule in ServiceNow to run on the table where these text fields exist. This rule should trigger on the 'before' or 'after' insert or update events, depending on your specific requirements.
In the Business Rule script, implement a regular expression pattern matching to search for PII/PHI data. Regular expressions are powerful tools for pattern matching, and they can help identify specific patterns like Social Security Numbers (SSNs) or other PII/PHI formats.
Here's an example of a regular expression that matches SSNs: /(^\d{3}-\d{2}-\d{4}$)|(^\d{9}$)/
Within the Business Rule script, retrieve the field values from the record being inserted or updated. Apply the regular expression pattern matching on these values to identify any PII/PHI data.
If a match is found, you can take appropriate actions, such as displaying an error message to the user, preventing the record from being saved, or triggering a workflow/notification to alert the necessary stakeholders.
Here's a sample code snippet in JavaScript, which can be used within the Business Rule:
(function executeRule(current, previous /*, g*/) {
var fieldValues = [current.field1, current.field2, current.field3]; // Specify the text fields to monitor
var regex = /(^\d{3}-\d{2}-\d{4}$)|(^\d{9}$)/; // Regular expression for SSN matching
for (var i = 0; i < fieldValues.length; i++) {
if (regex.test(fieldValues[i])) {
current.setAbortAction(true); // Prevent record from being saved
gs.addErrorMessage('PII/PHI data is not allowed in the field: ' + fieldValues[i]);
break;
}
}
})(current, previous /*, g*/);
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 08:24 PM
Hi @ericgilmore ,
I thought your question was related to AI and you were not looking for alternative solution !! Did you mistankenly marked the other answer correct?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 10:37 AM
Actually, you may be correct. Are you saying there IS a solution that would allow me to us AI for field validation?