- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 06:01 AM
Hi Team
i created a catalog item (Device req) & created Requested for filed as (username).
hear my requirement is, once i selected the username . email id will fill automatically in Email field.(email back end value is "email")
pls guide me how to achieve these through catalog client script
Thanks in advance 🧡🧡
Regards
khasim.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 08:01 AM
Use this
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ref = g_form.getReference('user_name', req_for);
}
function req_for(ref) {
g_form.setValue('email', ref.email);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 06:23 AM
Hello,
There are many solutions available online for this.
Adding few here.
Hope this helps.
Best regards,
Harshad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 06:24 AM - edited 11-07-2023 06:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 06:27 AM
In script include
var forIctuser = Class.create();
forIctuser.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserData: function() {
var usr = this.getParameter('sysparm_usr');
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', usr);
gr.query();
if (gr.next()) {
return gr.email.toString();
},
type: 'forIctuser'
});
Client:
function onLoad() {
//Type appropriate comment here, and begin script below
var abc = g_form.getValue('requested_by');
//alert('abcvalue:' +abc);
var ga = new GlideAjax('forIctuser');
ga.addParam('sysparm_name', 'getUserData');
ga.addParam('sysparm_usr', abc);
ga.getXML(processResponse);
}
function processResponse(response) {
var answer = response.responseXML.documentElement.getAttribute('answer');
alert(answer);
if (answer != '') {
// use backend names of catalog item variables
g_form.setValue('requested_for_email_address',email);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 07:13 AM
Hi,
You can use this in an onchange catalog client script, that runs on change of the user record
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ref = g_form.getReference('<user variable>', req_for);
}
function req_for(ref) {
g_form.setValue('<email field to populate>', ref.email);
}
}
