Getting Display form vs Edit Form data
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!!!
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!!!
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
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.
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.
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
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];
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.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 6 guests