Error message populating if the user's first name and last name is in AD throw an error in catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 12:54 AM
In Catalog item Form if we type the same first name and last name which is present in Active Directory it will throw an error on OnChange Function.
Thanks,
Ravichandra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 02:30 AM
Hello @Ravichandra2 ,
Could you please add some screenshot or what error it is displaying.
Thanks
Amarjeet Pal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 02:44 AM
I want Show the Error message when the user selects the name which is present in the sys_user table in a catalog item through the client script on change i tried with some script but it didn't work
This is the script i used
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 03:17 AM
Hi Ravichandra2,
You can't use GlideRecord in client script.For that you have to write a GlideAjax and fetch the server side value in the script include.
Please mark it as helful if it helps you.
Thanks & Regards,
Satyapriya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 03:24 AM
Hello @Ravichandra2 ,
Just a brief explanation of using GlideAjax . Hope you will find this Helpful
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('CheckUserName');
ga.addParam('sysparm_name', 'checkUser');
ga.addParam('sysparm_firstname', g_form.getValue('updated_firstname'));
ga.addParam('sysparm_lastname', g_form.getValue('updated_lastname'));
ga.addParam('sysparm_middleinitial', g_form.getValue('middle_intial_a'));
ga.getXML(function(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'true') {
alert('User Name already exists');
g_form.setValue('updated_firstname','');
g_form.setValue('updated_lastname','');
g_form.setValue('middle_intial_a','');
}
});
}
```
This version of the script creates a new instance of GlideAjax and provides it with the name of the server-side script to call (`CheckUserName`) and any necessary parameters (`firstname`, `lastname`, and `middleinitial`). It then calls the `getXML` method on the GlideAjax object to asynchronously execute the server-side script and receive its response.
The server-side script (`CheckUserName`) would need to be created separately in order for this code to work. The `checkUser` function within that script would accept the parameters provided by the client-side script, perform a query on the `sys_user` table using those parameters, and return a true or false value indicating whether a matching record was found.
Thanks
Amarjeet Pal