This project has moved. For the latest updates, please go here.

GetSPField within iframe

Apr 15, 2015 at 10:19 AM
It seems that GetSPField cannot be applied to the field on a form within an IFRAME.

In a scenario I faced I needed to load EditForm.aspx in an IFRAME. After the IFRAME loads I need to make some of the form's fields readonly via GetSPField().MakeReadOnly(), but the function throws "Unable to get a SPField named <field_name>";
Apr 15, 2015 at 12:55 PM
Can't you just put your SPUtility.js code on the EditForm like normal and then load it in the IFRAME?
Apr 16, 2015 at 7:51 AM
I can. But I need readonly functionality in the case described only. When user edits form as usual (not in my custom page with an IFRAME, but in a usual SharePoint way) I don't need to make fields read only. It's not a problem, of course, but a question of code flow. Thanks.
Apr 18, 2015 at 2:28 PM
Makes sense. How about this:
  • On the page with the IFRAME, when you load EditForm, pass a URL parameter to the form.
  • On EditForm, detect whether or not that URL parameter is present and make the fields read only.
Similar to this: