Update Field automatically

rss

Posted by TWendt - Feb 8 ’17 at 02:59

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

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 9 years 8 months 7 days
    #1 by Dmitry Kozlov Feb 8 ’17 at 07:46

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

  • TWendt
    Member
    Member for: 8 years 8 months 20 days
    #2 by TWendt Feb 8 ’17 at 08:06

    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

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 9 years 8 months 7 days
    #3 by Dmitry Kozlov Feb 9 ’17 at 09:58

    [#2]: 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
    Member
    Member for: 8 years 8 months 20 days
    #4 by TWendt Feb 10 ’17 at 07:36

    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

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 9 years 8 months 7 days
    #5 by Dmitry Kozlov Feb 13 ’17 at 03:05

    [#4]: 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
    Member
    Member for: 8 years 8 months 20 days
    #6 by TWendt Feb 15 ’17 at 06:54

    Hi Dmitry,

    thanks, it works now.

    Best wishes

    Tom

Displaying 1 to 6 of 6 messages