I have created a workflow to handle accepting / rejecting pages. It works fine except for one small detail: I cannot find out who published the page.
The workflow is handling the onPagePublished event provided by EPiServer.WorkflowFoundation.Activities.OnPagePublish. The second argument (EPiServer.WorkflowFoundation.Activities.WorkflowPageEventArgs e) should have the Identity field set, but it is the empty string. For other events this seems to work. As a workaround I tried Membership.GetUser() to see who the current user is, but this returns null. I also tried loading the PageData, but while the user who created/changed the page is part of the data I don't see the publisher anywhere.
Thanks for any help.
I would've guessed that user got put as ChangedBy. But maybe SetChangedOnPublish needs to be true.
Are you seeing the wanted username in the Admin Change Log Tool?
Yes, in the Change Log Tool I see the correct username in the Publish action. Is there a way to access this information programmatically?
If you are inside an event I'm unsure of the timing when the logging occurs but I would guess it's doable. Haven't tried or looked into it though. You could check using some reflector tool.
The change log is normally truncated regularly and can be disabled which needs consideration. You might want to keep investigating as the whole Change Log idea shouldn't be considered good practise :)
Ok, thanks for your help. One more question though: I thought that 'SetChangedOnPublish' might be a good workaround, but I can't get it to work. On my base page type I overrode 'SetDefaultValues' and set SetChangedOnPublish = true. When tracing with the debugger, it passes this point and executes the code. However, when the page is created and I examine it, this property is still false. Is there another step required?
Not sure of the current state and which version you are running but it's always been a bit messy to work with the the "Mark as changed" feature from code. Maybe these links will help you: