2

Trying to get 4 variables into my page content at a certain point: - Last Modified Date - Who it was modified By (user) - Created Date - Who it was created By

Am I able to pull these at all points in my content.

It seems I can use:

At the top of code and it will display at the top of the page, but I can't put that anywhere else? Still a bit of a newbie, sure there is a reason for that or another tag that has to go around it?

Is there a way to grab the information via javascript?

3
  • 2
    Hi, I am sorry, I am not following what you are asking. Where is the data coming from. Are you creating a custom page that pulls data from a list? Are you modifying a OOTB form in SharePoint? What it sounds like is you have a custom page that you are pulling the fields of a list or document from. Please explain your needs a bit better. – David Drever Jan 22 '16 at 5:54
  • I have custom pages that I want to pull this data for. The data would be relevant for that given page. When was this page last update, who updated it... etc.. – friedfishy Jan 22 '16 at 14:24
  • @friedfishy, plz provide a clear query as what u have and what u need. It is a little bit hectic to get the query here, after reading ur comments under the provided answers. – Md. Tahmidul Abedin Mar 26 '18 at 7:12
1

As per my understanding from your question, you want to get all 4 fields from a list mentioned above.To get that it is enough to use Author, createdBy, Editor and Modifiedby from the list item using sharepoint REST Api.

Please refer https://msdn.microsoft.com/en-us/library/office/fp142380.aspx. Hope it helps.

Thanks.

1
  • Not sure I totally understand. I want to add those 4 fields for the given custom page. So, I have mycustompage.aspx and somewhere on that page I want to display that given pages author, created date, edited, etc.. If this is done using REST, do you have a basic example to get started? – friedfishy Jan 22 '16 at 14:27
0

I assume your custom page is going to be stored in a list (site pages, or something similar). If not, you really need to provide more details in your questions. Quick note. Editor and Modified By are the same thing.

When accessing your page you will have the ID in the query string and you can grab it from there. Then using REST API you can access the field data:

var call = $.ajax({
   url: "http://<site url>/_api/web/lists/GetByTitle('ListTitle')/items('itemID')
   ,type: "GET",
   dataType: "json",
   headers: {
   Accept: "application/json;odata=verbose"
 }
 Success: function(data){
   var result = $.parseJSON(data.d);
   var authorField = result.Author;
   var createdField = result.Created;
   var modifedByField = result.Editor;

   // You now have the fields you are looking for.  Update your page fields as required from here.
 },
 Error: function() {Alert("Error Occurred!");
});

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.