need to display user email id based on user reference filed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2020 05:04 AM
i have created one catalog item under that created two variable
1. add user its referring to sys_user table
2. email id -string name -need to auto populate based on selected user.
actually my requirement is to show instead of name I want to show email id in the add user variable or else based on user selection on add user variable need to auto populate on user email in email id variable .PFA belwo screenshot.
can any one help me script
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2020 12:29 AM
And still you want this with combination of Client script and Script include then below is the approach.
Write onChange catalog client script on user variable.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('checkShortDescState');
ga.addParam('sysparm_name', 'checkAvailability');
ga.addParam('sysparm_check', newValue);
ga.getXML(HelloWorldParse);
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
g_form.setValue('variable name',answer);
}
}
Script include -
name - checkShortDescState
client callable - true
var checkShortDescState = Class.create();
checkShortDescState.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkAvailability:function()
{
var value=this.getParameter('sysparm_check');
var gdt = new GlideRecord('sys_user');
gdt.addQuery('sys_id',value);
gdt.query();
if(gdt.next()){
return gdt.email;
}
} ,
type: 'checkShortDescState'
});

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2020 05:33 AM
Hi Praveen,
In case you prefere to show Email address instead of Name then you need to alter the Display Value for the table (not recommended) as it will mean everywhere where User table is referenced will show Email address instead of Name & may not be ideal.
In case you will alternatively you can use ref_ac_columns attribute to show Email as below.
For ge.
ref_auto_completer=AJAXTableCompleter,ref_ac_columns=email,ref_ac_columns_search=true,ref_ac_order_by=name
Additionally, if you will to populate the Email field with selected user in the Presenter Email ID variable field then you can use an onChange() client script that runs when Variable1 (Presenter Email ID) field changes as below.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var getusermail=g_form.getReference('variable1',callback); //replace variable1 with proper variablename
function callback(getusermail)
{
g_form.setValue('variable2',getusermail.email); //replace variable2 with correct variable name
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2020 05:48 AM
The easiest way to do this is to use a lookup select box for your "Presenter Email ID's" field. Set the table to sys_user and set the Lookup Label and values as email.
Then add a variable attribute under the default value tab of is_searchable_choice
Gives you this:
If this was helpful or correct, please be kind and click appropriately!
Michael Jones - Proud member of the CloudPires Team!
Michael D. Jones
Proud member of the GlideFast Consulting Team!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2020 11:37 PM
In normal catalog item view below script is working.