Send Total of Child List to Parent List

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
jennifer_little
Posts: 10
Joined: Fri Mar 03, 2017

27 Feb 2017

Hello,

I have a parent list called Projects for example. I have a child list called tasks which is linked to the parent list with a unique project ID. I want to calculate the total of all related child tasks and input the project total into the parent list. Example shown below:


Parent List - Projects

Project ID Project Name Project Total

000-001 Project a £15.00


Child List - Tasks

Related Project ID Task name Task total

000-001 Task 1 £10.00

000-001 Task 2 £5.00


Thanks


Jennifer

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

28 Feb 2017

Hi,

You can calculate the total either in a workflow or with JavaScript directly in a 'Project' form containing a Related Items control with the related tasks. Please, find a sample in the thread:

viewtopic.php?f=1&t=592

If you need an assistance of our support team, send a request to support@spform.com

Cloud.Ed
Posts: 40
Joined: Fri Dec 04, 2015

14 Mar 2017

I am using the following code and Forms Designer 3.0.1.1. The code does not seem to set the var rows, any help?

var total = 0;
var rows = fd.relatedItems(0).data('ctx').ListData.Row;
rows.forEach(function(item) {
alert('Loop');
//total += parseFloat(item.Amendment_x0020_Amount)
});
alert(total)

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

15 Mar 2017

Hi,

Most likely, Forms Designer 3.0.1.1 does not support fd.relatedItems method. Please, expand the browser console (F12) and check the errors.

Cloud.Ed
Posts: 40
Joined: Fri Dec 04, 2015

16 Mar 2017

Here is the error returned:

Unable to get property 'Row' of undefined or null reference.

The version of the Forms Designer App is 3.0.1.1, I'm using the Forms Designer Client 3.1.4 on the Edit form.

Thanks again!

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

16 Mar 2017

Hi,
Could you provide a screenshot of your form with the Related Items control?

Cloud.Ed
Posts: 40
Joined: Fri Dec 04, 2015

16 Mar 2017

We have a total of 5 related items and this is the last, var rows = fd.relatedItems(4).data('ctx').ListData.Row;
001.png
001.png (48.14 KiB) Viewed 3962 times

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

17 Mar 2017

Hi,
Most likely, you retrieve an incorrect list view. Try to open the form in a browser, expand the browser console (F12), and type in the Console tab:
fd.relatedItems(0).data('ctx').ListTitle

Then change index in the 'relatedItems' to find the correct view.

Cloud.Ed
Posts: 40
Joined: Fri Dec 04, 2015

17 Mar 2017

This form opens in Model and the code fails. On a whim I set the form to open normal and the code works. Can you help?

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

20 Mar 2017

Are you sure that you put the code into the right form? I've just tested the following scenario in both, dialog and non-dialog modes, and everywhere it worked fine:
1. Inserted the code into the form:
alert(fd.relatedItems(0).data('ctx').ListTitle);
2. Tested in a dialog.
3. Tested in the non-dialog mode.

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 22 guests