Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Phillip Robinson 6 posts 26 karma points
    Aug 06, 2014 @ 17:48
    Phillip Robinson
    0

    ContentService sending to publish problems

    Hi

    I am currently working with the ContentService.SendingToPublish within my method I get the e.Entity and save its ID and a few other things to a database table for use later. I only want this to happen for editors and not for publishers, hence the reason I am hooking into the SendingToPublish event and only giving my editors the send to publish access.

    This all works perfectly fine when I edit an already published page but when I try to create a page this does not work. The e.Entity does not have a Node ID attached to it. This made sense to me so I tried to use the SentToPublish event assuming that this would be after the page was saved and therefore it would have an id attached to the e.Entity but there still was no ID.

    I then hooked into both the ContentService.Saved and ContentService.Saving and put a breakpoint in both of these methods, but when I click the "Save and send for approval" button these two breakpoints are not hit. Code below

    public class UmbracoEvents : IApplicationEventHandler
    {
        public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
        }
    
        public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            ContentService.SendingToPublish += ContentServiceSendingToPublish;
            ContentService.Saved += Saved;
            ContentService.Saving += Saving;
        }
    
        public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
        }
    
        private void Saving(IContentService sender, SaveEventArgs<IContent> e)
        {
            var breakpoint = string.Empty;
        }
    
        private void Saved(IContentService sender, SaveEventArgs<IContent> e)
        {
            var breakpoint = string.Empty;
        }
    
        private void ContentServiceSendingToPublish(IContentService contentSender, SendToPublishEventArgs<IContent> e)
        {
            var nodeId = e.Entity.Id;
            // Save node id to database table
        }
    }
    

    Am I missing something here? Does anyone know how I can get to the saved or saving node id?

    Thanks in advance.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Aug 06, 2014 @ 17:55
  • Phillip Robinson 6 posts 26 karma points
    Aug 07, 2014 @ 12:05
    Phillip Robinson
    0

    Hi Jeroen,

    Yes, I am using Umbraco 7.1.1.

    I have given the link you sent a read through and i'm not sure it applies to my issue. Even when I just hook into the ContentService.Saving += Saving; and ContentService.Saved += Saved; events and breakpoint them they do not get hit when my editor clicks "Save and send for approval".

    I have tried the same thing in a clean install of Umbraco 7.1.1. I have tested it and found what I think is a problem which I'm not sure if it is wanted behaviour or not.

    So when I have a user with access to be able to send to publish and create but not access to publish. When that user creates a page and then clicks the "Save and send for approval" the page does not get created and an error is thrown: Request error: The URL returned a 404 (not found): /umbraco/backoffice/UmbracoApi/Content/GetById=0

    But if I click the preview button the node gets saved correctly. Then once I click the Save and send for approval everything works correctly. The same thing happens if I click the little arrow on the Save and send for approval button and click the Save button first.

    Thanks

  • Terence Jee 16 posts 87 karma points
    Sep 03, 2015 @ 18:04
    Terence Jee
    0

    Was this ever resolved?

    I'm using Umbraco 7.2.8 and I'm trying to intercept the ContentService.SendingToPublish event whenever a "Send to Publish" action occurs.

    I set a breakpoint in that method and it works only when someone clicks the "Save and send for approval" button in the content area. But if someone clicks "Send to publish" with either the right-click or the Actions dropdown, it doesn't seem to trigger the SendingToPublish or SentToPublish event.

    Thanks.

    Terence

Please Sign in or register to post replies

Write your reply to:

Draft