Getting Display form vs Edit Form data

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
Hubbaroo
Posts: 60
Joined: Sat Sep 21, 2013

28 Apr 2014

I'm having a small issue getting data from the display form. The data is in a standard dropdown.

Here I get the data from the edit form if this form was opened from the edit form. This works because setting the varText will only work if the form was opened from the edit form.

varText = $('.ms-dlgFrame', window.top.document)[0].contentWindow.fd.field('Title').value();
varRelationID = $('.ms-dlgFrame', window.top.document)[0].contentWindow.fd.field('Potential_x0020_Client').value();
varRelationText = $('.ms-dlgFrame', window.top.document)[0].contentWindow.fd.field('Potential_x0020_Client').control('getSelectedText');

If varText fails I assume the form was opened from the display so I try to get the same data from the display form:

varText = $('.ms-dlgFrame', window.top.document)[0].contentWindow.fd.field('Title').control()._el().text();
varRelationID = $('.ms-dlgFrame', window.top.document)[0].contentWindow.fd.field('Potential_x0020_Client').control()._el().value();
varRelationText = $('.ms-dlgFrame', window.top.document)[0].contentWindow.fd.field('Potential_x0020_Client').control._el().text();

From the edit form is no problem. I just can't seem to get the ID and Text of the dropdown on the calling display form. I need both as I'll be setting the value of a cross site lookup.


Thank you!!!

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

29 Apr 2014

Hello,

You can get only text representation of a field on a display form. In your case I would recommend to add ID as the additional column of your lookup and place it onto the display form. Next, you can hide it via CSS but it will allow you to get lookup ID from the child form.

Hubbaroo
Posts: 60
Joined: Sat Sep 21, 2013

08 Sep 2014

I see what you are talking about. When I mouse over the lookup the url that it links to shows in the status bar in IE. That link has the ID in. Can we get that?


Thanks again.

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

10 Sep 2014

Yep, you can get it from the link. Try the following code:

Code: Select all

var url = fd.field('LookupField').control()._el().find('a').attr('href');
var id = /[\\?&]ID=([^&#]*)/.exec(url)[1];

Hubbaroo
Posts: 60
Joined: Sat Sep 21, 2013

10 Sep 2014

Great, that realy helped. That allows me to get details from any modal window no mater how many deap. And the clients realy like that they can do it from the display form. They say that they open a company form with related contacts. Then open a related contact with related activities. Then open a related activity and create a new update. If they had to go from view to edit each time that would be crazy! The best part is they can view the updates list and group on parent, grand parent, etc... You get the picture. Every other method I used required a hidden field. This is so much better.

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 13 guests