Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have a tool that imports content and saves it with userId -1 (importer tool user). When importing with this tool, there should be no content validation.
I also have a subscription to the ContentSaving event:
ContentService.Saving += OnSaving;
private void OnSaving(IContentService sender, ContentSavingEventArgs e)
foreach (var node in e.SavedEntities)
if (node.WriterId != -1)
Which all works fine when importing, the WriterId is -1 and the validation doesn't occur, so the content is saved.
Now when a I log in and and save that data (different userId), this event is hit again. I want the validation to occur. This time the expected behaviour is because the user isn't -1 then the Validate() function should be called.
However I'm finding that the id is still -1 for the WriterId, so the Validate() function doesn't fire. This saves the user, then updates the WriterId to my userId, so when I save again this time the validation fires.
Assuming this is because it's checking the current state and getting the writerId rather than getting the userId from user saving?
How do I get the correct userId of the user performing the save action in the Content.Saving event?
Have you tried getting the current back office user? Off the top of my head I can't be certain how you do that though.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted