Catalog Client Script for validating User ID and email based on user inputs , in case if it exist pop user to change it as it not availabe. 2.User ID auto populating on the form as first_name.last_name and emai as first_name.last_name@3com.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2017 04:24 AM
Requirement of 1.catalog Client Script which could validate User ID and email based on input ,in case if it already exist pop user to change it as it not available.
2. User ID auto populating on the form as first_name.last_name and emai as first_name.last_name@3com.com both to be editable feilds.
Regards,
Sam

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2017 06:37 AM
Hi Sachin,
Both of these are completely do-able. For the first one I recommend using a GlideAjax call to a script include that verifies the name/email is available.
For the second, you can simply use an onChange client script that takes the content of the first field and appends the appropriate suffix for you.
Docs: Client Scripts
Docs: GlideForm
Docs: GlideAjax
Client Script Best Practices - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2017 07:11 AM
Hi Chuck,
I am new to SCripting had used below to check ID but it not working,Can you please let me know the changes needs to be done.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var userID = g_form.userID;
var gr=new GlideRecord('sys_user');
gr.addQuery('userID',userField);
gr.addQuery('user', usrID);
if(gr.next())
alert("Entered User ID already Exists. Please change the value");
g_form.setValue('userID','');
//Type appropriate comment here, and begin script below
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2017 08:32 AM
Try this:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var userID = g_form.userID;
var gr=new GlideRecord('sys_user');
gr.addQuery('user_name', userID);
if(gr.next())
alert("Entered User ID already Exists. Please change the value");
g_form.setValue('userID','');
//Type appropriate comment here, and begin script below
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2017 08:45 AM
Hi Chuck
Thanks for the script. but as user id is entered on the form its disappearing.Even if its new userid is entered
Any advice.
Regards,
Sam