1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Last Edit Date and Last Editor Name

Last Edit Date and Last Editor Name

8 posts, 0 answered
  1. Jon
    Jon avatar
    41 posts
    Registered:
    20 Oct 2010
    20 Dec 2010
    Link to this post
    Hi Ivan,

              Is there a way to get the last edit date and the last editor name from the PageNode object ?
    Thanks in advance.
    Jon
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    20 Dec 2010
    Link to this post
    Hi Jon,

    The PageData has properties LastModifiedBy and and LastModified

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Jon
    Jon avatar
    41 posts
    Registered:
    20 Oct 2010
    21 Dec 2010
    Link to this post
    Hi Ivan,

             The code below illustrates how to get the LastModifiedBy. However, it returns a Guid object. I need a way to get the name of the person once I get this Guid object. Is there a method that you are supposed to call that passes the Guid object that can get the persons name that last modified the page ? Is there another way of getting the name ?

    Regards.
    jon
    PageManager pManager = PageManager.GetManager();
                   string title = page1.Page.Title.ToString();
                   PageData page = pManager.GetPageDataList().Where(t => t.Title == title).SingleOrDefault();
                   dateModified = Convert.ToString(page.LastModified);
                   Guid gui = new Guid();
                   gui = page.LastModifiedBy;
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    21 Dec 2010
    Link to this post
    Hello Jon,

    LastModifyBy is a property that gets or sets the ID of the user that last edited the item. You can use Telerik.Sitefinity.Security.SecurityManager.GetFormattedUserName(id) to return the name of the user or SecurityManager.GetPrincipalName

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Jon
    Jon avatar
    41 posts
    Registered:
    20 Oct 2010
    21 Dec 2010
    Link to this post
    Hi Ivan,

            For some reason ( maybe this is a bug ) LastModifiedBy keeps returning null. page.Owner however, works fine in my code. Got any ideas ? I'm not sure why this is happening. I modified the page too.

    Heres is my code .. simple .
    jon

    PageManager pManager = PageManager.GetManager();
    PageData page = pManager.GetPageDataList().Where(t => t.Title ==title).SingleOrDefault();
        dateModified = Convert.ToString(page.LastModified);
        Guid gui = page.LastModifiedBy; <---- RETURNS AN EMPTY GUID OBJECT EVERY TIME 
        modifiedBy = SecurityManager.GetPrincipalName(gui);
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    21 Dec 2010
    Link to this post
    Hello Jon,

    Ok, you can use the VersionManager to get the latest version and the modifier together with all other data

    sample

    var itemId = node.Page.Id;
     
    var vManager = VersionManager.GetManager();
    var history = vManager.GetItemVersionHistory(itemId);
    var first = history.First();
    var change = new WcfChange(first);
    var mod = change.CreatedByUserName;


    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Jon
    Jon avatar
    41 posts
    Registered:
    20 Oct 2010
    22 Dec 2010
    Link to this post
    Hi Ivan,

            Could you give me the assembly for VersionManager and WcfChange. I'm missing the assembly and my IDE will not resolve it for me ..

    Thanks in advance,
    jon
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    22 Dec 2010
    Link to this post
    Hi Jon,

    VersionManager is part of Telerik.Sitefinity.Versioning
    WcfChange is part of Telerik.Sitefinity.Versioning.Web.Services, but instead of using WcfChange which was just for the sample you can use Telerik.Sitefinity.Versioning.Model.Change and its public property Owner which is Guid. This is the version owner which you can resolve

    var user = UserManager.GetManager().GetUsers().Where(usr => usr.Id == changeOnwerId).FirstOrDefault();
    if (user != null)
      {
           var myser = (user.FirstName ?? "") + " " + (user.LastName ?? "");
     
      }


    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
8 posts, 0 answered