Catalog Item Price Doubled/Added Instead of Quantity Multiplication
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @nameisnani ,
The base price is already added by the catalog, so calculate only the incremental price difference.
Try something like this in your script include for the function checkQuantity
var priceupdate = 'AUD;' + ((quantity - 1) * getitem.price);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi @nameisnani ,
The likely root cause is the Price implications setting on the reference variable u_quantity_reference. When enabled, ServiceNow adds the referenced record's price to the catalog item's base price, potentially causing double counting.
For example, if the base price is AUD 11.80 and the referenced record contributes AUD 23.60, the total becomes AUD 35.40 instead of AUD 23.60.
Solution:
Open the catalog item and navigate to its Variables related list.
Open u_quantity_reference and check Price implications.
If you disable Price implications as referenced screenshot, the referenced record's price will no longer automatically contribute to the catalog item's total through that variable. However, the existing script may not work as intended if it relies on that price contribution.
If you want to retain Price implications, and the base price is already included, adjust the calculation to return only the incremental price as @Chirag Pathak says
var priceupdate = 'AUD;' + ((quantity - 1) * getitem.price);Test both approaches with different quantities to confirm the final price. The incremental calculation is appropriate only if the base price is already included in the total.
If this answer helps, please mark it as helpful.
Thankyou
Yamsani Bhavani
ServiceNow Developer - SecOps, GRC, Custom Applications, Now Assist