Creating pages programatically, expected events not firing


Hi, I'm having issues getting the expected events firing when creating pages programtically.

I've hooked up events in an InitializableModule.

When I publish a page like this:

contentRepository.Save(page, SaveAction.Publish | SaveAction.SkipValidation, AccessLevel.NoAccess);

The events fired are:

Shouldn't DataFactory.Instance.SavingContent and DataFactory.Instance.SavedContent be fired as well?

When I save pa page like this:

contentRepository.Save(page, SaveAction.Save | SaveAction.SkipValidation, AccessLevel.NoAccess);

The event fired are only DataFactory.Instance.CreatedContent. For sure the Saved and Saving should fire to?

Am I missing something here?

Jan 29, 2016 12:12

Save events triggers only on existing content I think

Jan 29, 2016 12:51

Try updating one of the pages above and publish it again and see if it triggers?

Jan 29, 2016 12:53

Hi. Yes so it seems.

The code below triggers the Save events. The Publish Saveaction never seem to trigger them though, but that could be by design I guess.

var newPage = contentRepository.Save(page, SaveAction.Publish | SaveAction.SkipValidation, AccessLevel.NoAccess);

var fetchedPage = contentRepository.Get<PageData>(newPage);

var clone = p.CreateWritableClone();
contentRepository.Save(fetchedPage, SaveAction.Save | SaveAction.SkipValidation, AccessLevel.NoAccess);

In my case I just ended up moving my stuff to the Publish event instead.

Jan 29, 2016 13:31
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.