Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

Creating pages programatically, expected events not firing

Vote:
0

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:
DataFactory.Instance.PublishingContent
DataFactory.Instance.CreatedContent
DataFactory.Instance.PublishedContent

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?



#143727
Jan 29, 2016 12:12
Vote:
0

Save events triggers only on existing content I think

#143735
Jan 29, 2016 12:51
Vote:
0

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

#143738
Jan 29, 2016 12:53
Vote:
0

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.

#143742
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.