Is it possible to read fields from related items view, and how?

rss

Posted by eedoh - Mar 14 ’14 at 09:00

Basically, I have a list of contracts, and a list of change orders. There's a lookup field to the contracts in change orders list. I placed related items (change orders) view on the contracts form. I'd like to sum all the change order amounts and add them to the contract value field in the contracts list.

Is this possible, and if so, how??

 

Thanks

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 8 months 29 days
    #1 by Dmitry Kozlov Mar 17 ’14 at 05:34

    Hello,

    You can create a view with aggregation and then select it in the Related items settings. Go to the 'change orders' list, click the 'Create View' button on the ribbon, choose 'Standard View', expand 'Totals' section and choose aggregation column.

    Next, you should select the new view in the Related items settings in Forms Designer.

    And finally, you can copy Total value into the parent field via JavaScript.

  • pgmacca
    Member
    Member for: 4 years 5 months 29 days
    #2 by pgmacca Dec 22 ’14 at 01:13

    I am in the process of evaluating the Forms Designer, and I have been able to get everything to work, except for the ability to copy/ reference the Aggregated total.

     

    Could you please add some information in relation to your last line, as to how to "Copy" the value using Javascript.

     

    TIA

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 8 months 29 days
    #3 by Dmitry Kozlov Dec 22 ’14 at 08:55

    [#2]: Hi,

    Could you send HTML-source of your form page to [email protected]?

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 8 months 29 days
    #4 by Dmitry Kozlov Dec 23 ’14 at 01:07

    [#2]: Hi,

    We've received your message, thank you. Please, use the following code to retrieve the aggreagtion value via JavaScript:

    var value = $('.POLineItems .ms-listviewtable > tbody > tr > td:eq(2)').text().replace('Sum= $', '');

  • Katy
    Member
    Member for: 4 years 11 months 2 days
    #5 by Katy Jan 12 ’16 at 04:37

    [#4]: Could you please explain how i can use the same solution for my project? How i can insert name of my related item into this code and field name?

  • rostislav
    rostislav
    Moderator
    Member for: 4 years 1 month 13 days
    #6 by rostislav Jan 13 ’16 at 09:37

    [#5]:

    1. You related items control must be in client render mode for this code to work

    2. Enter a CSS class name for the related items control, we'll use "myitems"

    3. Use the following code, replacing "myitems" with your CSS class name, and "3" with the number of the column containing the aggregation number, starting from 0 (not 1).

     $('.myitems .ms-listviewtable > tbody > tr > td:eq(3)').text()

    4. The text you'll get back you may have to trim to get only the numeric value

  • Katy
    Member
    Member for: 4 years 11 months 2 days
    #7 by Katy Jan 13 ’16 at 10:05

    [#6]:

    Thank you, i've done everything but i am only getting the copy of first number from the related item, not the sum of all numbers.

  • rostislav
    rostislav
    Moderator
    Member for: 4 years 1 month 13 days
    #8 by rostislav Jan 13 ’16 at 01:27

    [#7]:

    In that case you can play around with the number in td:eq(3), increasing or decreasing it. Otherwise, you can send the html of the page to [email protected]

  • Katy
    Member
    Member for: 4 years 11 months 2 days
    #9 by Katy Jan 20 ’16 at 02:20

    [#8]: Thanks for the reply and sorry for delay.

    That didn't help :-( I did a workaround and included subtotal view on a separate tab as i was in a hurry. It serves the purpose but i would really like to make the Total field work. I'll get back to that issue later.

Displaying 1 to 9 of 9 messages