Is there a way to use a Dictionary Entry Calculated value to total a related list

Christopher Dan
Kilo Contributor

I have a related list on a form that I need a currency column to total up to a field on the form. I want to use a Dictionary Entry Calculate Value to total so it totals instantly without an update to the record of the related list. Is this possible?

21 REPLIES 21

ghsrikanth
Tera Guru

FYI, calculate will not change the value immediately - it needs you to save the record or update the record.


Its doesn't function like onChange script.



For your requirement, its better to go for onChange client script


How would I write an onchange to update the actual spend amount when the ledge 7000.01-Salaries & Wages, actual Cost changes?


find_real_file.png


On seeing the design its better to go for before Business rule as there are two tables involved -


In this case, the before business rule should be on Work order cost table -


This BR should run on Insert, Update, and Delete also



I assume there is a relation to the work order cost table and to the parent task (Intercompany work order record), there should some reference   - if I assume.


Write a before BR


Insert, Update, Delete checked


Any new activity happens in the work order cost table -


Script-


var amt = 0;


if (current.operation() == "insert" || current.operation() == "update")


        amt = current.u_actual_cost;



if(current.operation() == "delete")


      amt = -previous.u_actual_cost;



var grTask = new GlideRecord('task');


if(grTask.get(current.order_task)){ //this field should hold the task sys_id to which these work order cost refers


        grTask.u_actual_cost = grTask.u_actual_cost + amt; //if the operation is delete, then it will subtract the previous cost, if it is update or insert, its just puts the value


      grTask.update();


}



Hopefully it helps


I actually have a BR right now but it will not update when the actual cost for that ledger changes because that ledgers actual cost is a Calculated Value from a total off the time card associated with the form. But when I change the time card that change does not apply to the form actual spend amount because I first have to go into the Ledge to update it before it will calculate it properly.