Is there a way to use a Dictionary Entry Calculated value to total a related list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2016 12:30 PM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2016 12:01 AM
I updated your script with log statements, please run this and go to log table and put source = debugCostOrder
Please verify whether the log statements are printing -
function onBefore(current,previous){
var amt = 0;
if (current.operation() == "insert" || current.operation() == "update")
amt = current.actual_cost;
if(current.operation() == "delete")
amt = -previous.actual_cost;
gs.log("Actual Cost Amount: " + amt, 'debugCostOrder');
var grTask = new GlideRecord('task');
if(grTask.get(current.work_order)){
gs.log('Task Number: ' + grTask.number, 'debugCostOrder');
gs.log('Task Amount before update: ' + grTask.actual_spend_amount, 'debugCostOrder');
grTask.actual_spend_amount = grTask.actual_spend_amount + amt;
grTask.update();
}
}
Hopefully it helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2016 06:57 AM
So the script says update or insert in it when there is never and update or insert. the Actual Cost field for that ledger is on the Work order cost table and is a Dictionay Calculate Field that pulls the total from a field on the main form which is called labor costs. The labor costs gets its total from the calculation total of the time card entries on the form. So I think maybe an onChange client script would work the way I need it to? Does that help describe the configuration better?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2016 07:04 AM
The thing with the calculated field is, it is not onChange field, the value in the calculated field will get reflected after saving the record only.
So from your observation, it seems the business rule is not triggering in the first place, even though the Actual Cost Amount got updated but as it is calculated from multiple values, the BR didnt get trigger?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2016 07:17 AM
correct it does not get triggered until I actually go in the record and select Update
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2016 07:16 AM
And I ran the BR and nothing showed in the log until I selected update on the actual form. So that why I think an onchange is needed because I need it to update automatically.