- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-28-2016 03:43 AM
I have multi line field on my catalog in which I need values populated from a table . There is a field "user" in my table which should be mapped to "requested for" field in catalog form.
If both the fields (user == requested for ) matches then I need to display the rest of the field values from the table for that user in the multi line text field in my catalog form.
Please guide how this can be done.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-28-2016 04:05 AM
1) Create an onChange Client Script on the requested_for variable with below code
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('UserInfoUtils');
ga.addParam('sysparm_name','getUserInfo');
ga.addParam('sysparm_user',newValue);
ga.getXML(getInfo);
function getInfo(response) {
var info = response.responseXML.documentElement.getAttribute('answer');
g_form.setValue('multi_line_text_variable_name',info);
}
2) Create a script include as below.
Name: UserInfoUtils
Client callable: true
script:
var UserInfoUtils= Class.create();
UserInfoUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserInfo : function()
{
var info = '';
var grUser = new GlideRecord('table_name');
grUser.addQuery('sys_id', this.getParameter('sysparm_user'));
grUser.query();
if(grUser.next())
{
info += 'Label1 : ' + grUser.field_name1 + '\n';
info += 'Label2 : ' + grUser.field_name2 + '\n';
.........
........
}
return info.toString();
},
type: 'UserInfoUtils'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-28-2016 03:52 AM
You can have an onChange catalog client script on the variable 'Requested for' in which you have to check if the selected requested_for user exists in ur table. If exist, then fetch all the other values of that user record and populate it in multi text field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-28-2016 04:05 AM
1) Create an onChange Client Script on the requested_for variable with below code
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('UserInfoUtils');
ga.addParam('sysparm_name','getUserInfo');
ga.addParam('sysparm_user',newValue);
ga.getXML(getInfo);
function getInfo(response) {
var info = response.responseXML.documentElement.getAttribute('answer');
g_form.setValue('multi_line_text_variable_name',info);
}
2) Create a script include as below.
Name: UserInfoUtils
Client callable: true
script:
var UserInfoUtils= Class.create();
UserInfoUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserInfo : function()
{
var info = '';
var grUser = new GlideRecord('table_name');
grUser.addQuery('sys_id', this.getParameter('sysparm_user'));
grUser.query();
if(grUser.next())
{
info += 'Label1 : ' + grUser.field_name1 + '\n';
info += 'Label2 : ' + grUser.field_name2 + '\n';
.........
........
}
return info.toString();
},
type: 'UserInfoUtils'
});