- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2017 03:19 PM
HI,
Im trying to get display value of a reference field. I know of the method g_form.getDisplayBox(), but I am trying to do it from ajax call.
I am only able to get the sys id of the reference field.
I tried the following but no luck.
Client side:
ga.addParam('sysparm_field_sysID',g_form.getValue('reference_field'));
script include:
var val1=this.getParameter('sysparm_field_sysID'); ans=val1.getDisplayValue() ; |
How can I use getDisplayValue() in a script include or I cannot, please help me?
regards
AMit
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2017 03:39 AM
Hi Amit,
Please check the script below.
client script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
var test= g_form.getValue('enter your reference field');
var check = new GlideAjax('your script include name');
check.addParam('sysparm_name', 'script include function name');
check.addParam('sysparm_comp', test);
check.getXML(analyzeResponse);
function analyzeResponse(response)
{
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
}
script include:
name: test
Must be checked as client callable
var test= Class.create();
auto_fill_lochypcomp.prototype = Object.extendsObject(AbstractAjaxProcessor, {
test: function()
{
var test= this.getParameter('sysparm_comp');
var grp = new GlideRecord('sys_user');
grp.addQuery('name',test);
grp.query();
while(grp.next())
{
//now you can perform your query here.
}
},
type: 'test'
});
I hope it will help you.
Thanks,
Harshvardhan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2017 02:53 AM
You'll need to create an object of AbstractAjaxProcessor in a class within the Script Include, and a GlideAjax object within your client script.
We cover this on our Scripting Course - have you attended that at all?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2017 09:40 AM
Hi Dave,
I probably haven't attended it, that is why the confusion..
I will surely read it

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2017 03:39 AM
Hi Amit,
Please check the script below.
client script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
var test= g_form.getValue('enter your reference field');
var check = new GlideAjax('your script include name');
check.addParam('sysparm_name', 'script include function name');
check.addParam('sysparm_comp', test);
check.getXML(analyzeResponse);
function analyzeResponse(response)
{
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
}
script include:
name: test
Must be checked as client callable
var test= Class.create();
auto_fill_lochypcomp.prototype = Object.extendsObject(AbstractAjaxProcessor, {
test: function()
{
var test= this.getParameter('sysparm_comp');
var grp = new GlideRecord('sys_user');
grp.addQuery('name',test);
grp.query();
while(grp.next())
{
//now you can perform your query here.
}
},
type: 'test'
});
I hope it will help you.
Thanks,
Harshvardhan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2017 09:39 AM
Thanks Harsh vardhan, it helped.