Getting Display form vs Edit Form data

rss

Posted by Hubbaroo - Apr 28 ’14 at 06:09

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!!!

 

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 10 months 26 days
    #1 by Dmitry Kozlov Apr 29 ’14 at 03:33

    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
    Member
    Member for: 5 years 10 months 26 days
    #2 by Hubbaroo Sep 8 ’14 at 04:43

    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.

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 10 months 26 days
    #3 by Dmitry Kozlov Sep 10 ’14 at 08:33

    [#2]: Yep, you can get it from the link. Try the following code:

    var url = fd.field('LookupField').control()._el().find('a').attr('href');
    var id = /[\\?&]ID=([^&#]*)/.exec(url)[1];
    
  • Hubbaroo
    Member
    Member for: 5 years 10 months 26 days
    #4 by Hubbaroo Sep 10 ’14 at 10:09

    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.

Displaying 1 to 4 of 4 messages