Hello,
I hope someone can help me. I created a javascript to calculate a column in a subgrid, but it it not working. I will add the javascript code below:
Hello,
I hope someone can help me. I created a javascript to calculate a column in a subgrid, but it it not working. I will add the javascript code below:
Like a33ik said, its not a recommended way.
You also use rollup field.
For science, it could be done this way:
const gridCtrlName = "Subgrid_new_6"; const gridCostAttrName = "hrex2193_cost"; const costAttrName = "hrex2193_coursetotalcost"; function onLoadCostTable(execCtx) { const formCtx = execCtx.getFormContext(); gridCtrl = formCtx.getControl(gridCtrlName); gridCtrl.addOnLoad(setTotalCost); } function setTotalCost(execCtx) { const formCtx = execCtx.getFormContext(); const gridCtrl = formCtx.getControl(gridCtrlName); const costAttr = formCtx.getAttribute(costAttrName); const getValue = (row) => row.data.entity.attributes.get(gridCostAttrName).getValue() ?? 0; const rows = gridCtrl.getGrid().getRows().get(); const totalCost = rows.reduce((total, row) => total getValue(row), 0); if (totalCost !== costAttr.getValue()) { costAttr.setValue(totalCost); } }
Of course, the calculation is only for the first page of the sub-grid. The cost can therefore be wrong for more than one page.
Hello,
I would highly recommend using some backend operations for doing calculations like plugin/workflow/power automation flow.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,214 Most Valuable Professional
nmaenpaa 101,156