- 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:09 AM
Hi,
So you would require onbefore transform script for this
What did you start with and where are you stuck?
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:13 AM
Hi Ankur,
Many thanks for the response.
We tried few possibilities but no luck.
And We are new to Transform scripts.
Could you pls provide us the sample script.
And also instead of Transform scripts, Is there any way to achieve this ???
Because some times end user directly import the on custom table level.
Many thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 12:14 AM
Hi,
since you mentioned while importing you can use before insert BR as well on that table
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:18 AM
Hi Ankur,
Many thanks for the reply.
Okay, will work around on Business rule logic.
Could you please provide the sample script for Transform Script logic.
Advance thanks.