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?
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.
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.
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
Am I missing something here? Does anyone know how I can get to the saved or saving node id?
Thanks in advance.
Hello,
Are you using Umbraco 7?
Some events work different in v7. This might help:
http://issues.umbraco.org/issue/U4-3695
http://our.umbraco.org/forum/developers/extending-umbraco/46369-Umbraco-7-events-how-to-catch-the-creating-event
Jeroen
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
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
is working on a reply...