Script needed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2024 09:02 AM
Hi all,
I need a script for the below requirement
we have the field called queue owner email id , if we type without '@' it should give alert "Incorrect format. please enter xxx@xxx.com". During onchange i need to validate it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2024 09:12 AM
Hi @Saib1 ,
You can use below script if you only want to check text contains @ or not. Writing onchange client script.
if (!newValue.includes('@')) {
g_form.addErrorMessage('Incorrect format. Please enter xxx@xxx.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
10-29-2024 09:21 AM - edited 10-29-2024 09:25 AM
We did something similar, but the contrary, in our case, we don't want them to add the "@domain.com" because we added some automation behind.
Here is an example, already modified to your case, you will create a Catalog Client Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
var regex = /@/;
if (!regex.test(newValue)) {
getMessage('Incorrect format. Please enter xxx@xxx.com.',function(msg){
alert(msg);});
g_form.clearValue('queue_owner_name');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2024 05:07 PM
@Saib1 Why not just specify validation Regex to be "Email"?
Execution result:
If you want to change the error message, go to "Service Catalog" - "Catalog Variables" - "Variable Validation Regex".
Select Email and change text in "Validation message"