- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 06:20 AM
Hello,
Any on please help me on the below scenarios.
1)Employee name variable should contain only alphabets.
2)date of entry field must accept only current date (as per system date) and not past or future date.
Thanks in advance.
Sravya
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 06:29 AM
Here is how you can validate date through ui policy
No Code date validations through (Catalog) UI Poli... - ServiceNow Community
For the check on name try this
Create onChange Client Script on that particular field.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var field = g_form.getValue('fieldname');
if (!field.match(/^[A-Za-z ]*$/)) {
alert('Please enter only text');
g_form.clearValue('fieldname');
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 06:31 AM
For the 2nd one, use Catalog UI Policy
For 1st one, you need to regex code.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 06:29 AM
Here is how you can validate date through ui policy
No Code date validations through (Catalog) UI Poli... - ServiceNow Community
For the check on name try this
Create onChange Client Script on that particular field.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var field = g_form.getValue('fieldname');
if (!field.match(/^[A-Za-z ]*$/)) {
alert('Please enter only text');
g_form.clearValue('fieldname');
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 06:31 AM
For the 2nd one, use Catalog UI Policy
For 1st one, you need to regex code.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 06:36 AM
Hello Sravya,
In one hand, I will create a regex validation rule inside Service Catalog > Variables > Validation Regex, and I'll add a new regex rule for checking if it's only characters on that name field, this regex can work: [a-zA-Z]
. Check this link: https://www.servicenow.com/community/developer-articles/service-portal-catalog-items-regex-field-val...
In the second hand, I will use the default value inside default value tab and use something as follows: javascript: new GlideDateTime().getDate(). Also if you only want current date, past or future date it's now supposed to be allowed, then make it read only from dictionary definition.
☆ Community Rising Star 22, 23 & 24 ☆
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 06:42 AM - edited 01-23-2024 06:42 AM
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************