Query table data to display in a Service Catalog field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2019 11:05 PM
Hi Community,
I have a question about Service Catalog variables.
<field A> A user selects an item name (in the image below, the variable name is "u_item_name_men")
<field B> A user selects whether or not s/he wants the item new or second hand ("u_item_newreuse_men")
(this is not yet described in the code below, just wanting to add in the future)
<field C> Unit price of A item depending on A&B's selection ("u_item_unitprice_men")
A, B, and C are in the same variable set "u_vset_men".
The table I want the data to reference is "u_uniform_item_master".
The Catalog Client Script is like the image below:
As the result, nothing is displayed...
What part do i write wrong?? Could anyone give me some tips??
Thanks in advance.
Lit
- Labels:
-
Best Practices
-
Instance Configuration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2019 03:58 AM
Which value gives you null popup message?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2019 06:04 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2019 09:31 PM
Hi
Can you paste your Script include and Client script code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2019 09:47 PM
Hi Omker,
sure. Please check below.
Script Include:
var setUnitPrice = Class.create();
setUnitPrice.prototype = {
getUnitPrice : function() {
var target = this.getParameter('sysparm_item_name');
var gr = new GlideRecord('u_uniform_item_master');
gr.addQuery('u_item_name', target);
gr.query();
if(gr.next()){
return gr.u_item_price;
}
},
type: 'setUnitPrice'
};
Client Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var target = g_form.getValue('u_item_name_men');
var ga = new GlideAjax('setUnitPrice');
ga.addParam('sysparm_name', 'getUnitPrice');
ga.addParam('sysparm_item_name', target);
ga.getXML(setPrice); function setPrice(response)
{
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
g_form.setValue('u_item_unitprice_men',answer);
}
}
The client script is in the variable set "u_vset_men".
The variable "u_item_name_men" (also created under the same variable set) is set in variable name field.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2019 09:52 PM