Page 1 of 1

Getting Display form vs Edit Form data

Posted: 28 Apr 2014
by Hubbaroo
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!!!

Re: Getting Display form vs Edit Form data

Posted: 29 Apr 2014
by Dmitry Kozlov
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.

Re: Getting Display form vs Edit Form data

Posted: 08 Sep 2014
by Hubbaroo
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.

Re: Getting Display form vs Edit Form data

Posted: 10 Sep 2014
by Dmitry Kozlov
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];

Re: Getting Display form vs Edit Form data

Posted: 10 Sep 2014
by Hubbaroo
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.