- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 12:08 AM
Hi All,
Can anyone please help on the below requirement.
We have below three fields on custom table level and while importing we need to check like
1. If the Date type field data entered as MM:DD:Year instead of DD:MM: Year then we need to auto check the Error checkbox field.
2. If the String field value entered as Alpha numeric values then we need to check the Error checkbox field.
Table fields:
1. Date ---> Date type
2. Description ----> String type
3. Error ----> Checkbox type
Advance thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 01:43 AM
Hi,
then something like this
Use regular expression for the date format validation and Alpha numeric
I assume you are comfortable in using RegEx in ServiceNow. If not you will find many examples on community and other blogs
https://www.codegrepper.com/code-examples/javascript/regex+for+date+mm%2Fdd%2Fyyyy
Regular Expression for alphanumeric and underscores
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
var date = source.u_date;
var description = source.u_description;
// use regular expression to validate date format
if(<regex is not satisfied || regex of alphanumeric is not satisfied>)
target.u_error = true;
})(source, map, log, target);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 12:23 AM
Hi,
which fields from import set you want to validate?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 12:26 AM
Hi Ankur,
Thanks for the response.
"Date" -----> Type Date field
And
"Description" ---> Type String field.
We need to set the Error checkbox field as True.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 12:31 AM
Hi,
you are talking about target field then which fields are present in the import set?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 12:50 AM
Hi,
In excel also same fields are available.
Date and Description.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 01:43 AM
Hi,
then something like this
Use regular expression for the date format validation and Alpha numeric
I assume you are comfortable in using RegEx in ServiceNow. If not you will find many examples on community and other blogs
https://www.codegrepper.com/code-examples/javascript/regex+for+date+mm%2Fdd%2Fyyyy
Regular Expression for alphanumeric and underscores
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
var date = source.u_date;
var description = source.u_description;
// use regular expression to validate date format
if(<regex is not satisfied || regex of alphanumeric is not satisfied>)
target.u_error = true;
})(source, map, log, target);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader