Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Get Catalog variable value from a widget

Ashwin perumal
Tera Contributor

Hello All,
I have a order guide which has a Lookup select box variable "Model" referenced to Vendor Items table(pc_vendor_cat_item). In this variable I am display the product model names as choices for the user. My requirement to display the price of the user selected model in "Order Guide Details" section from Sc order widget at the time of form submission.

Ashwinperumal_1-1762916439565.png

 



Ashwinperumal_0-1762916071068.png

 

In OOB it displays the catalog item price and so I cloned the widget and added the below server side logic trying to hardcode the model sysid in server script and get the value and display in price using html.

Server script:

data.modelPrice='';
var gr = new GlideRecord('pc_vendor_cat_item');
gr.addQuery('sys_id','b0f089da37313000158bbfc8bcbe5d0b');
gr.query();
if(gr.next()){
data.modelPrice=gr.getDisplayValue(('price'));
gs.log("Portal Value: " + data.modelPrice);
}
 
HTML :
In Html I changed the OOB script for displaying price as below
<td class="wrapper-sm v-middle text-a-c hidden-xs hidden-sm">
<span><strong>{{::data.modelPrice}}</strong></span>
</td>

The above script works for  hardcoded model sysIds but how should I dynamically get the user selected model and then pass to the server script of the widget so it will display the price of model exactly.

Could anyone please help me to retrieve the value of variable and pass it in the dynamicly to server side and print the price. Thanks in advance.



 
0 REPLIES 0