This project has moved and is read-only. For the latest updates, please go here.

Trying to access an SPFieldFile object in the DispForm page

Dec 16, 2015 at 4:52 PM
Edited Dec 16, 2015 at 4:53 PM
I'm trying to get information regarding a document library record in the library display form, including the document link. The DispForm.aspx page source includes the following:
<td nowrap="true" valign="top" width="113px" class="ms-formlabel"><h3 class="ms-standardheader"><a name="SPBookmark_FileLeafRef"></a>Name</h3></td>
        <td valign="top" class="ms-formbody" width="350px" id="SPFieldFile">
        <!-- FieldName="Name"
             FieldInternalName="FileLeafRef"
             FieldType="SPFieldFile"
          -->
            <span id='WPQ24162078d-3214-491c-ac55-1367234ae9acFileLeafRef' data-sp-control='SPFieldFile' data-sp-options='{&quot;mode&quot;:1,&quot;source&quot;:&quot;FileLeafRef&quot;}'></span>
</td>
I've tried both GetSPField('Name') and GetSPFieldByInternalName('FileLeafRef'), but neither work, resulting in this error:

SCRIPT5022: Error creating field named Name: Unable to retrieve the input control for Name
File: sputility.min.js, Line: 10, Column: 3302

Should I expect this to work?
Mar 23, 2016 at 2:27 AM
shawnc1959,
Sorry for the super late reply, I missed your post somehow. I've actually been working on support for DispForm recently. I made some progress in v0.13.0 where it should be able to do GetValue for all fields. SetValue only works for some of the fields right now though.

Regarding the name column specifically, you should be able to do something like this:
SPUtility.GetSPField('Name').GetValue()
// will return "Test Document.docx"
Thanks,
Kit