Update page programmatically - show "edited" icon

Vote:
 

Hi, 

i am trying to updated pages programmatically, which works fine. However, i want to have the page to show the edited icon shown below:

if i update the page via the UI it shows, however, saving the page programmatically doesnt show any indication that the page is updated, i have to click the page to get the "Ready to be published" in the UI. 

Even if i reload the entire edit mode, it doesnt reflect the pages in the pagetree which is updated.

this is the code i am using to save the page

var saveAction = SaveAction.ForceNewVersion;
var newReference = _contentRepository.Save(page, saveAction, EPiServer.Security.AccessLevel.NoAccess);
_contentVersionRepository.SetCommonDraft(newReference);

Any suggestions of how to align those states?

#269755
Jan 10, 2022 15:52
Vote:
 

Hi Jannich,

So you're basically trying to set the in-use notification.

From the client side, you can make a post request to /EPiServer/cms/Stores/inusenotification/

You'll have to submit the following parameters in the body:

  • contentLink (for example, 6_132)
  • languageBranch
  • addedManuelly (true/false)
  • created (datetime)
  • modified (datetime)

You can achieve the same using IInUseNotificationRepository:

_notificationRepository.AddInUseNotification(new InUseNotification
{
    LanguageBranch = page.LanguageBranch,
    ContentGuid = page.ContentGuid,
    User = HttpContext.User.Identity.Name,
    AddedManually = false
});

Hope this helps!

#269807
Jan 11, 2022 11:13
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.