You need to sign in to do that
Don't have an account?

Calculate total cost based on matching PO numbers
Hi,
I have an object with custom fields "po_number" and "repair_cost" and would like to add a third field "total cost" calculated on the SUM of the repair_cost field for any records that have matching po_number fields.
Could I do some sort of read of the po_number field and then a loop? (I know this is not the proper syntax, I hope I'm getting the idea across though) i.e. FOR(VALUE in po_number) do SUM(repair_cost)
or could I read in the value of the po_number field on the current record, then calculate to total cost based on any matching values on other records?
I have an object with custom fields "po_number" and "repair_cost" and would like to add a third field "total cost" calculated on the SUM of the repair_cost field for any records that have matching po_number fields.
Could I do some sort of read of the po_number field and then a loop? (I know this is not the proper syntax, I hope I'm getting the idea across though) i.e. FOR(VALUE in po_number) do SUM(repair_cost)
or could I read in the value of the po_number field on the current record, then calculate to total cost based on any matching values on other records?
It seems you wat to create a roll up summary field within same object to calculate the sum based on matching po_number but currently salesforce doesn't support that and there is one similar idea posted https://success.salesforce.com/ideaView?id=08730000000BrqGAAS to have this feature based on Hierarchy relationship.
But in your case its better you should create another object having Master relationship to this object and calculate total sum using roll up summary or usinf simple trigger if you create lookup relation.
Let me know if that helps or provide some more detail on your issue s might help you with some better solution
Thanks
All Answers
It seems you wat to create a roll up summary field within same object to calculate the sum based on matching po_number but currently salesforce doesn't support that and there is one similar idea posted https://success.salesforce.com/ideaView?id=08730000000BrqGAAS to have this feature based on Hierarchy relationship.
But in your case its better you should create another object having Master relationship to this object and calculate total sum using roll up summary or usinf simple trigger if you create lookup relation.
Let me know if that helps or provide some more detail on your issue s might help you with some better solution
Thanks
https://success.salesforce.com/answers?id=90630000000CnmlAAC