Catalog Item Price Doubled/Added Instead of Quantity Multiplication
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
13m ago
Hi Team,
I'm facing a pricing issue with a catalog item.
Catalog Item Price: AUD 11.80
Expected:
I have a Reference variable (u_quantity_reference) that points to records in a custom table (u_order_guide_quantity).
For testing, I updated the quantity record:
My current calculation in the Script Include is:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.clearValue('u_quantity_reference');
var quantity = g_form.getValue('u_quantity');
var ga1 = new GlideAjax('OrderGuideUpdateQuantity');
ga1.addParam('sysparm_name', 'validateQuantity');
ga1.addParam('sysparm_quantity', quantity);
ga1.addParam('sysparm_cat_item', g_form.getSysId());
ga1.getXML(HelloWorldParse1);
function HelloWorldParse1(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer != '') {
g_form.clearValue('u_quantity');
g_form.showFieldMsg('u_quantity', answer, 'error');
} else if(quantity>1) {
var ga = new GlideAjax('OrderGuideUpdateQuantity');
ga.addParam('sysparm_name', 'checkquantity');
ga.addParam('sysparm_quantity', quantity);
ga.addParam('sysparm_cat_item', g_form.getSysId());
ga.getXML(HelloWorldParse);
}
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('u_quantity_reference', answer);
}
}
}
checkquantity: function() {
var getcatitem = this.getParameter('sysparm_cat_item');
var quantity = this.getParameter('sysparm_quantity');
var getitem = new GlideRecord('sc_cat_item');
getitem.get(getcatitem);
var getquantity = new GlideRecord('u_order_guide_quantity');
getquantity.addQuery('u_quantity', quantity);
getquantity.addQuery('u_item_name', getcatitem);
getquantity.query();
if (getquantity.next()) {
return getquantity.sys_id;
} else {
var priceupdate = 'AUD;' + (quantity * getitem.price);
var recinsert = new GlideRecord('u_order_guide_quantity');
recinsert.initialize();
recinsert.setValue('u_quantity', quantity);
recinsert.setValue('u_price', priceupdate);
recinsert.setValue('u_item_name', getcatitem);
var sysId = recinsert.insert();
return sysId;
}
}Question
Why is the catalog item price (AUD 11.80) being added to the price stored in the referenced u_order_guide_quantity record?
Is this expected behavior for a Reference variable with pricing, and what would be the recommended approach to achieve:
can anyone please help me with the fix
where i exactly i need to modidy in script
@Ankur Bawiskar please hlp me
Expected should be : Quantity 2 = AUD 23.60
Thanks in advance
