Description:
I am having trouble with a script that is supposed to calculate the quantity of a product in an editable subgrid in the quote form in Dynamics 365 Sales. The script is triggered by an OnChange event on the "number of pieces" field in the subgrid and is supposed to calculate the product quantity based on the number of pieces and the unit volume of the product.
The script I am using is:
function CalcQdt(context){ var pecas = (context.getFormContext().data.entity).attributes.getByName("cr452_quantidadedepecas"); var VolUn =(context.getFormContext().data.entity).attributes.getByName("cr452_volumeun"); var QDT =(context.getFormContext().data.entity).attributes.getByName("quantity"); if (pecas != null && VolUn != null) { var pecas = pecas.getValue(); var VolUn = VolUnField.getValue(); var quantity = pecas * VolUn; quantityField.setValue(quantity); } }
However, when I make changes to the "number of pieces" field, nothing happens. I have checked the code and there are no syntax errors. Can anyone help me figure out what is going wrong with this script?