Skip to main content
Question

Calculate grand total of a dynamic table rows

  • 4 September 2024
  • 4 replies
  • 47 views

I am displaying related opportunity line items data in a table using TableRow for an opportunity. Number of rows depend on number of opportunity line item records for an opportunity. I want to calculate grand total of TotalPrice column for all the opportunity line items which are displayed dynamically. As i don’t know how many rows i will get in the table, how do i proceed with the formula field? In formula field set up, i don’t see such option anywhere. Any help is much appreciated!

Hi @Sravyabm ,

Are you using the “eSignature for Salesforce” product? Or are you using “Gen for Salesforce”? I assume you’re using the eSignature merge fields based on your description, but please correct me if I’m wrong.

Unfortunately, the eSignature for Salesforce merge fields do require you to set up a template in advance, and to specify the TableRow number if the merge field is linked to a related list object field. There’s no way to place one row and expect it to generate additional rows dynamically based on how many rows in your table there need to be. However, this is something our Gen for Salesforce can absolutely do. 

Gen for Salesforce is designed to dynamically generate documents, including custom tables with related list data, and can be quite flexible when trying to produce a table of data, including calculating a grand total.

Many customers utilize Gen to produce this kind of dynamic table on a document, then use eSignature to send that document out for additional data collection and/or signature.

Hope this helps!


Hi @Jesse.Morgan thanks for responding. I have installed docusign package for salesforce and created Docusign Gen template on Opportunity object. I have uploaded a word document which contains the below table. When i preview this template, it is generating 2 rows for an opportunity which I picked. All values are correctly populated. To calculate location totals i.e., sum of all rows data of MonthlyCost, i would like to know if there’s any tag/formula which is supported by Docusign. If not, please let me know if there’s any workaround. Thank you!

 


Hi @Sravyabm , If you already have the monthly “TotalPrice” calculated in a field on the Opportunity, then I recommend mapping a Gen merge field to that Opportunity TotalPrice field and putting that in the cell. Gen leverages XPath 1.0, which means you can try and also use its Sum function. This may or may not work for your use case, but it’s worth trying. You’ll need to adjust the name of the actual field though. My example is using the Total_Cost__c field so replace that with your own field’s API name. 

<#<Content Select=”sum(//Opportunity//OpportunityLineItems/Total_Cost__c)” /> #>

 


P.S. whatever your total cost field is, make sure you also select that field in the “Fields” step within your Gen template.


Reply