locked
Calculate a Opportunity field totalled line item fields RRS feed

  • Question

  • Hi Forum,

    I am attempting to implement my own Tax calculation through javascript that used custom tax fields and I have it working on the Opportunity product forms as I want, however I would like to add a custom total tax field to the Opportunity form and populate it with the totals of my custom fields on the line items.

    Is this possible, preferably through JavaScript as we are still in the process of understanding Plugin development, and would prefer a lighter weight solution such as Jscript.

    Thanks!

    - Spike.

    ps. If you require more details don't hesitate to ask.

    Thursday, August 16, 2012 2:09 AM

Answers

  • This is definitely possible through javascript by retrieving the line items through the REST endpoint. You can refer to this sample to help you through

    http://msdn.microsoft.com/en-us/library/gg334427

    You would basically need to use SDK.REST.retrieveMultipleRecords pass the name of your entity and modify the select statement passing the name of the opportunity field in the line items entity (ie. ParentOportunity) plus the GUID of the Opportunity your are currently working with. Then loop through the result set and sum them up for the totals.

    You can get the needed JS files in the SDK.

    Hope that helps.

    Thursday, August 16, 2012 8:32 AM