- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2024 11:09 PM
Hi,
I have a requirement that the email service catalog variable should accept only the *@company.com format, where * can be any name. It will not accept @gmail, @Yahoo, or any. Kindly help.
Regards
Suman P.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2024 11:51 PM
Hi @Community Alums ,
You can create Regular expression in ( question_regex ) table. As mentioned below.
Expresssion : ^[a-zA-Z0-9._%+-]+@testcompany\.com$
Now in catalog item select single line text as a variable and in Type Specification section there is field called validation regex in that select regular expression which you created above in question_regex table.
Please mark my response as correct and helpful if it helped solved your question.
Thanks,
Rohit Suryawanshi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2024 11:14 PM
You can refer to this previous article
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2024 11:20 PM - edited ‎11-17-2024 11:22 PM
Hi @Community Alums ,
You can use below script in onchange catalog client script, i am assuming email_id is variable in this case. You can replace with actual variable name.
var email = g_form.getValue('email_id');
if (email.indexOf('@runjay.com') == -1){
g_form.clearValue('email');
g_form.addErrorMessage('Add email containing @runjay.com');
}
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2024 11:34 PM
Hi @Runjay Patel,
What does this line explain?
if (email.indexOf('@runjay.com') == -1){
Regards
Suman P.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2024 11:42 PM
If entered email does not contain (@runjay.com) then whatever is entered in email field for e.g 'Test@mail.com' it will clear that from email variable
It is a sort of restriction for user to use @runjay.com in mail
If my answer helped you in any way, then mark it as helpful or correct. This will help others finding a solution.
Thanks,
Raj