Update Field automatically

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
TWendt
Posts: 109
Joined: Mon Sep 08, 2014

08 Feb 2017

Hi all,

i calculate the Software costs from a related items lists with javascript. For example

var total = 0;
var rows = fd.relatedItems(5).data('ctx').ListData.Row;
rows.forEach(function(item) {
total += parseFloat(item['Kosten.'])
});
fd.field('Kosten_x0020_Software').value(total);

If i add a new row in the related items list i must press save two times to update the field "Kosten". Is it possible to update the field automatically?


Best wishes

Tom

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

08 Feb 2017

Not sure I undertood what Save button you mean. Do you use the related items in the quick edit mode?

TWendt
Posts: 109
Joined: Mon Sep 08, 2014

08 Feb 2017

Hi Dmitry,

i have a calculated field named "costs total" where the costs from the field hardware, software, maintenance are sum up. If i press the save button the field "costs total" is not updated. I must open the form again and if i press save again, the field is updated.

What must i do?

Best wishes

Tom

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

09 Feb 2017

The code you use looks right, it should updata the total immidiately after adding/removing rows. Just replace this:

fd.field('Kosten_x0020_Software').value(total);
with

fd.field('Kosten_x0020_Software').control()._el().html(total);
If it does not help, I recommend you to purchase 100 support minutes and provide temporary access to your form.

TWendt
Posts: 109
Joined: Mon Sep 08, 2014

10 Feb 2017

Hi Dmitry, many thanks, it works. But one question, is it possible to sum this five fields (Bold) to a field named total costs?

For example:

Three sum fields (Hardware, Software and Maintenance) filled by javascript.
var total = 0;
var rows = fd.relatedItems(5).data('ctx').ListData.Row;
rows.forEach(function(item) {
total += parseFloat(item['Kosten.'])
});

fd.field('Kosten_x0020_Software').control()._el().html(total);
and two calculated fields (Internal programming and User training) filled by a sharepoint formula
=[Number of days]*500

Best wishes

Tom

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

13 Feb 2017

You can use the same forumula in JavaScript and calculate a field value dynamically. Or probably, you can get a calcualte value like other field values: fd.relatedItems(5).data('ctx').ListData.Row[0]["CalcField"]

TWendt
Posts: 109
Joined: Mon Sep 08, 2014

15 Feb 2017

Hi Dmitry,

thanks, it works now.

Best wishes

Tom

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests