3

I make it in sharepoint online.

<tr>
     <td valign="top" class="ms-formlabel"><nobr>Created by</nobr></td>
         <td valign="top" class="ms-formbody">
            <SharePoint:CreatedModifiedInfo ControlMode="Display" runat="server">
               <CustomTemplate>
                    <SharePoint:FormField FieldName="Author" runat="server" ControlMode="Display" DisableInputFieldLabel="true" />
                    <SharePoint:FieldValue FieldName="Modified" runat="server" ControlMode="Display" DisableInputFieldLabel="true"/>
                </CustomTemplate>
            </SharePoint:CreatedModifiedInfo>
     </td>
</tr>

But it just worked with Modified, not work with Author. Many thanks for your support.

2

Created By and Modified By don't make sense on a New Item form, these don't get set until the item is saved. This is why you don't see it on the stock SharePoint NewItem form, it only exists on the DispForm and the EditForm.

If you wanted to "hack it in" you could scrape the current user information from the DOM and inject it into the page.

  • Thanks for your answer. By the way, FieldName Modified show "5/14/2015 11:11 PM" but I modified it on "5/14/2015 4:11PM". What going on here? Hope you can answer this question. – user2903937 May 15 '15 at 3:27
  • Probably time zone offsets – Eric Alexander May 15 '15 at 12:00
0

I found the issue: I make it in NewForm.aspx. In this page. Author can not found because no one create it. To solve this problem. You can use javascript to handle this:

var openMenuSelector = $('.ms-core-menu-root[title="Open Menu"]');
var currentUserDisplayName = openMenuSelector.length > 0 ? openMenuSelector[0].firstChild.data : '';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.