You are viewing limited content. For full access, please sign in.

Question

Question

Sum of 2 Table fields

asked on January 31, 2017

Hi All,

I am trying to add together 2 fields that are in separate tables to a currency field out side of these

I have attached a image of how the form looks, trying to ADD Office Total and Tech total together and be populated in Grand Total

I have Scripting around all the other fields that are working perfectly

 

I have tried using the advanced calculation with :-

=SUM(variable_2.Office_Total,variable_3.Tech_Total)

This creates a 0 amount in the total but never changes

I have tried adding the same CSS (grandtotalsub) to Office Total and Tech Total and then the CSS (grandtotal) to Grand Total

I tried this javascript

$(document).ready(function () {
    $(document).on('blur change', '.sum input', sumtotal);
    function sumtotal() {
        var s = 0;
        $('.grandtotalsub input').each(function () {
            s += parseNumber($(this).val());
        });
        $('.grandtotal input').val(s);
    }
    function parseNumber(n) {
        var f = parseFloat(n); //Convert to float number.
        return isNaN(f) ? 0 : f; //treat invalid input as 0;
    }
});

What am I missing or need to change?

Regards

Shane

LF Issue.JPG
LF Issue.JPG (67.65 KB)
0 0

Replies

replied on February 1, 2017

I've a form that uses that option successfully. I used the =SUM(Table1_Total, Table2_Total) format. I assume you've confirmed that your variables are correct by passing them into a template metadata field or such. Yes?

replied on February 1, 2017 Show version history

Hi Shane,

I created a test form and this is how I have it configured. 

The first table total calculation is: =SUM(INDEX(Table.N1,ROW()),INDEX(Table.N2,ROW()))

The second table total calculation is: =SUM(INDEX(Table_1.N1,ROW()),INDEX(Table_1.N2,ROW()))

The total field calculation is: =SUM(Table.Total,Table_1.Total)

 

Thanks,

Michael

0 0
replied on February 1, 2017

Hi Michael,

That should work but for some reason isn't,

Now what I get is a 0 Amount against the Office total and the Tech Total.

I was using Java for this which is working (I did take the scripting out so there wasn't Calculations and Java running together)

I am wondering if because I am using Javascript for sending data to the Office Clean SubTotal and the Office Protect Subtotal (and the tech totals) that this is causing an issue?

I used this

=SUM(INDEX(OfficeTotals.Office_Clean_Subtotal,ROW()),INDEX(OfficeTotals.Office_Protect_Subtotal,ROW()))

=SUM(INDEX(TechTotals.Tech_Clean_Subtotal,ROW()),INDEX(TechTotals.Tech_Protect_Subtotal,ROW()))

=SUM(OfficeTotals.Office_Total,TechTotals.Tech_Total)

 

0 0
replied on February 1, 2017

Shane,

 

   I'd previously used JavaScript for a form, but switched to the method I outlined when Forms 10.1 came out. I'll attach the business process I created so that you can take a look at it. I had to change the extension to .txt to upload, so you'll need to change it back to .xml on your end.

 

Thanks,

Michael

1 0
replied on February 16, 2017

Cheers Michael, makes sense :-)

0 0
replied on February 1, 2017 Show version history

I should have asked which version of Forms you're using. The technique I outlined came out in 10.1 I believe.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.