Sum in realted item

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

27 Dec 2018

Dear RMIC,
You might want to also replace "." with nothing, so the JS doesn't consider it when counting:

Code: Select all

total += parseFloat(item['BetragHauswaehrungNetto'].replace('.','').replace(',', '.'));
Cheers

RMIC
Posts: 96
Joined: Sun May 10, 2015

07 Jan 2019

Hello Nikita,

it works. Thanks for your help.

I have one more question: When I delete an element in the Quickedit, the deleted element is also used in the calculation. How can I prevent this?

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

07 Jan 2019

Dear RMIC,
Hmm, this shouldn't happen, but if it does, you can try switching to Synchronous Refresh, it might help with this issue:
SyncRefresh.png
SyncRefresh.png (3.55 KiB) Viewed 2369 times
If you face issues with duplicate rows for newly added items, please, find a workaround here - viewtopic.php?f=1&t=2172&p=6915

Hope this helps!
Cheers

RMIC
Posts: 96
Joined: Sun May 10, 2015

07 Jan 2019

Hello Nikita,
unfortunately, Synchronous Refresh does not work. The deleted item is still used in the calculation. How can this be fixed?

Yes, I have the problem with duplicate lines. I inserted the script from your link. However, it does not work.

Code: Select all

var rows = fd.relatedItems (0) .data ('ctx'). ListData.Row;
var dupes = {};
var singles = [];

$ .each (rows, function (i, el) {
     if (! dupes [el.ID]) {
         dupes [el.ID] = true;
         singles.push (el);
     }
});
My relatedItem is the "0" (fd.relatedItems (0)).

I have the Skirpt in the JavaScript Editor and on my calculation button, both can not be done. What am I doing wrong?

Many Thanks!

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

10 Jan 2019

Dear RMIC,
This seems to be some sort of issue with SharePoint List View... The only thing I can think of, would be to add a new button, which would update Related Items, then the calculation should go smoothly. Try the following code:

Code: Select all

fd.relatedItems(0).data('ctx').clvp.RefreshPagingEx('');
Please, note that updating Related Items takes time, depending on the amount of items in the list, and the code is async, so it's impossible to run the calculation straight after update, it should finish first.

Let me know if this helps or not!
Cheers

RMIC
Posts: 96
Joined: Sun May 10, 2015

11 Jan 2019

Dear Nikita,

It works. Thanks!

Can you explain why this does not work with the Synchronous Refresh.

User avatar
AlexZver
Posts: 232
Joined: Mon Aug 27, 2018

14 Jan 2019

Hi RMIC!

In fact, a Synchronous Refresh option works in server-side rendering mode only. If set to Synchronous, each time you filter/sort data, the page refreshes.

Timothyhef
Posts: 4
Joined: Sun Jan 27, 2019

01 Feb 2019

I would also like to share that after putting on view > show formulas, some lines with the =SUM still appeared as such =SUMnumber1,number2 instead of displaying the correct answer. Pls see Line 90 of this updated file.

User avatar
AlexZver
Posts: 232
Joined: Mon Aug 27, 2018

04 Feb 2019

Hi!

Could you please provide the screenshot?

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 7 guests