Summing Values in List and Displaying Total on Screen

I have created a custom Entity for a client to allow them to capture Associate resource details against Opportunities.

I have a list which allows multiple Associates to be recorded. The client would like the total cost for all entries to be calculated and displayed on the screen. This total also needs to be displayed in the Opportunity Totals block on the Opportunity Summary screen, alongside Total Quotes Value and Total Orders Value.

I've been digging around for inspiration but I am at a loss as to how to achieve this.

Advice would be appreciated!

  • 0

    John

    If you have access to the .NET API then you can pretty easily create a screen that combines a list block and a summary grid beneath it. You can do it in the ASP script but it would be a little more time consuming.

    The calculation would be done each time the screen is loaded. Unless you are driving behaviour like escalation rules then you would not need to store the totals.

    The Opportunity Total Screen is a screen like any other and is called OETotalsBox.

    You could very easily add a new field to the Opportunity Table and have that field displayed on screen. You could then use the 'Dummy Field' technique that I have discussed elsewhere on the community to calculate and display the total cost.

  • 0

    Thanks Jeff.

    Do you have any example code that might be used to perform the sum function on the field?

    I have added a field "Total Cost" to the OETotals screen.

    I am assuming I need to do something in the Create Script but can't seem to put together the right code.

    I've tried this to no avail:

    var mySQL = 'select sum(asso_totalcost) as mytotal from Associates'
    var myQuery = CRM.CreateQueryObj(mySQL,"");
    myQuery.SelectSQL();
    crm.fields(‘oppo_associate_cost_calc').value() = myQuery.FieldValue('mytotal’);
    I want to be able to store the sum of the associated Associate costs to this field in Opportunity to be used for reporting.