Page 1 of 1

Get Related Item Values

Posted: 03 Oct 2017
by joetel8
Hello,

I have a related item that displays a record row of data values that I would like to capture using Jquery.

I have a related item that has 3 columns (Assigned, Processed and Cost). This Related item view has one record returned.
I want to get the value of each column record returned.

Can this be done?

I know how to count number values for each row to get a total but I don't know how to get the text value of a particular column.

Any help you can assist me with is appreciated.

Thank you,

Joe

Re: Get Related Item Values

Posted: 03 Oct 2017
by Nikita Kurguzov
Hello, Joe!
It's fairly straightforward.
fd.relatedItems(0).data('ctx').ListData.Row; - this command returns all rows from the first Related Items control on your Form as JS array with all rows stored as objects. Count goes from zero, like in regular JS.

fd.relatedItems(0).data('ctx').ListData.Row[0]; - this command will return first row from the first Related Items control as an object.

fd.relatedItems(0).data('ctx').ListData.Row[0].Title; - this command let's you access the specific value you are looking for, in my case I am getting the value of the Title column for the first row of the first Related Items control. Change Title to the name of your field and you are good!

You can also use browser's console on the Form to experiment a little and find what you should use in your code:
RelatedItemsConsoleCommands.png
RelatedItemsConsoleCommands.png (12.18 KiB) Viewed 1823 times

Re: Get Related Item Values

Posted: 06 Oct 2017
by joetel8
Thank you Nakita that was a great help. As for getting the value of a people picker. How do i just get the text value and not all the other information that comes with the people picker field.

Thank you again for your assistance.

Joe

Re: Get Related Item Values

Posted: 06 Oct 2017
by Nikita Kurguzov
Hello, Joe!
For getting and setting Field values check out this article on our site, it has a lot of information, including methods for Client and Server People Picker - https://spform.com/javascript-framework ... eld-values

If you'll still need the help with implementation, please let me know.

Re: Get Related Item Values

Posted: 11 Oct 2017
by joetel8
Thank you Nikita for your assistance.

I get several elements when I execute this (fd.relatedItems(0).data('ctx').ListData.Row[0].EES_AssignedTo;) See below.
I need one addition piece of information that is provided when I execute the this:

[{…}]
0
:
{id: "201", title: "Shy, Renee", email: "rshy@ingenesis.com", sip: "rshy@ingenesis.com", picture: "https://ingenesisinc-my.sharepoint.com: ... MThumb.jpg", …}
length
:
1
__proto__
:
Array(0)

I need the "name" provided in the "title:" section in this case(Shy, Renee).
Is there something else I need to add to the above script to get the name?

Thank you for your assistance.

Joe

Re: Get Related Item Values

Posted: 12 Oct 2017
by Nikita Kurguzov
Hello, Joe!
It returns an array where the first element is the object that you need, plus you need to access title property.
So all you need to do is use this command:

Code: Select all

fd.relatedItems(0).data('ctx').ListData.Row[0].EES_AssignedTo[0].title

Re: Get Related Item Values

Posted: 19 Oct 2017
by joetel8
Thank you Nikita that worked perfectly.