SharePoint 2010: Get Created-By information in edit form with jQuery

If you ever tried to extract the “created by” user information in a SharePoint2010 edit form, you probably noticed that there’s no out-of-the-box solution for this situation. I think i might have found a work-around. I used jQuery to extract the user name from a rendered SharePoint control.

Step 1: Add the following SharePoint control to your form. This will render some additional HTML code, but you can place this control easily within a hidden table row.

<SharePoint:FieldValue ControlMode="Display" FieldName="Author" DisableInputFieldLabel="true" runat="server"/>

Step 2: Add the following lines to your jQuery document.ready() function and you’ll get the author from the selected item.

var author;
author = $('a[href^="/_layouts/userdisp.aspx?"]').text();

Advertisements
SharePoint 2010: Get Created-By information in edit form with jQuery

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s