Forum Discussion
cm
8 years agoIdeator II
Hi Chris
I've modifyied your code to meet my specific filed names and tried both ways - as a client event 'onAfterNew' or 'onShowItem' and as a property event 'onEditFinish'. Neither works.
This is what I have:
// get item ID
var po_pos_id = this.item.querySelector("#" + relatedID);
// get item properties
var po_pos_quantity = parseFloat(aras.getItemProperty(po_pos_id, "pr_pos_quantity"));
var po_pos_price = parseFloat(aras.getItemProperty(po_pos_id, "pr_pos_price"));
var po_pos_ppu = parseFloat(aras.getItemProperty(po_pos_id, "pr_po_priceper"));
// make sure we have all the pieces to calculate the total
if (po_pos_quantity !== 0 && !=isNaN(po_pos_quantity) && po_pos_price !== 0 && !=isNaN(po_pos_price) && po_pos_ppu !== 0 && !=isNaN(po_pos_ppu)) {
// Calculate the total
var total = po_pos_quantity * (po_pos_price / po_pos_ppu);
// Set the total
aras.setItemProperty(po_pos_id, "pr_pos_value", total);
// Refresh the form so this new value appears
aras.uiReShowItemEx(this.item.id, this.item);
}
When I added the code to the property event I couldn't use the input grid anymore. Whenever I tried to jump from one field to another the form seemed busy and didn't allow me to change the information once something was entered, mostly 'NaN' for number fields.
I have an item type called purchase_order. This item contains a related item type called po_lines which should contain single items with a description, quantity and so on. Therefore I think your suggested solution should work as this is in a relationship grid, shouldn't it?
I'm doing something wrong, but I have no idea what it is.
Chris