Email and requested by Autopopulate on catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 04:22 AM
Hi Experts,
I am working on one catalog item, in that 1. Requested By 2. Requested For Email address these are two variables, for these type is reference and reference table is sys_user .
1. Requested By for this I am using default value --- javascript:gs.getUser().getRecord().getValue('email');
this should be working fine, in the same way 2. Requested For Email address is also autopapulated ( shanthi priya kakarla Email I'D ) , for this I am using script include Please help me on this requirement.
script include.
var forIctuser = Class.create();
forIctuser.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserData: function() {
//get parameter
var usr = this.getParameter('sysparm_usr');
gs.info(usr + ' | ' + 'CSKCheck');
var usrDataObject = {};
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', usr);
gr.query();
if (gr.next()) {
//get backend names of fields from table or custom table
usrDataObject["eMail"] = gr.email.toString(); // if field type is reference use "getDisplayValue();" instead "toString();"
}
gs.info('MSK:' + usrDataObject["eMail"]);
var json = new JSON();
return json.encode(usrDataObject);},
type: 'forIctuser'
});
Catalog Client Script:
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 != '') {
var ret = JSON.parse(answer);
// use backend names of catalog item variables
g_form.setValue('requested_for_email_address', ret.eMail);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 08:26 AM
@ersureshbe did this worked for you?
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 06:13 AM
Hi, You can use g_user.userID and use getReference() field and achieve it. Use below script is the sample one.
function onChange(control, oldValue, newValue, isLoading)
{
var caller = g_form.getReference('caller_id', doAlert); // doAlert is our callback function }
function doAlert(caller) { //reference is passed into callback as first arguments
if (caller.vip == 'true')
alert('Caller is a VIP!');
}
Suresh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 06:17 AM
We have an Auto-populate section while creating a field in catalog items, there you can select the Dependent Question as a User reference field and start with the Dot walk path. In the Dot walk path, you will be able to see the fields from the user table, so that you can easily auto-populate the value without writing the script.