Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Overriding automatic return to Edit workflow state View modes: 
User avatar
Member
Member
brien-anca - 7/18/2011 10:07:18 PM
   
Overriding automatic return to Edit workflow state
I have a doctype managed with workflows, but after the document is published, there is sometimes some minor tweaking required (eg: move an image) which doesn't require running through the whole workflow again, but any press of the save button, forces the document back into the top of the workflow again.

Is there a way to override the Save event to not switch the workflow step back to edit? Should I use events on TreeNodeHandler for this? Is there a simpler way?

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 7/19/2011 10:33:22 AM
   
RE:Overriding automatic return to Edit workflow state
Hi,

Well, this would be probably best managed in the custom TreeNodeHandler,
OnAfterUpdate method. There is no easier way except for turning off the Workflow or using a Versioning without workflow, although that would create many versions in the version history.

You can find inspiration in the Workflow internals - API - Changing workflow step.

Regards,
Zdenek

User avatar
Member
Member
brien-anca - 7/20/2011 11:54:17 PM
   
RE:Overriding automatic return to Edit workflow state
Hi,

I tried this but unfortunately, the workflow step has already been changed by the time the system fires the OnAfterUpdate event (or the OnBeforeUpdate event for that matter), so I can't figure out if this event is a regular save during an edit session, or a save from a published state. Can you tell me where in the code base the core save action is located so I can modify the core source?

User avatar
Member
Member
brien-anca - 7/24/2011 10:10:06 PM
   
RE:Overriding automatic return to Edit workflow state
Hi,
Any progress on this one?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 7/25/2011 1:59:34 AM
   
RE:Overriding automatic return to Edit workflow state
Hi,

I would like to ask you how you want to distinguish whether the change is minor or major and doesn't/does require workflow process in the code? You can do it using the custom tree node handler - but this will be applied to all changes and you will have to check it somehow in your code when to push the document to publish step and when not.

That is the meaning of workflow - when something is changed, even a small thing, it should through the approval process, because sometimes even small change can cause big damage (imagine that someone would just change a product price - add or remove a zero...) and you should keep a record who changed it and who approved it.

So, it is up to you to decide whether you really need a workflow or not for your documents.

Best regards,
Juraj Ondrus

User avatar
Member
Member
brien-anca - 7/25/2011 4:20:08 PM
   
RE:Overriding automatic return to Edit workflow state
Even if someone accidentally presses Save with no changes, it reenters the workflow. Since translators are an outsourced resource, we don't want a translation cycle automatically activated for such accidents, or trivial publishing changes like moving an image. This workflow is for articles that once published are not intended to be changed.

My intention was, from within an update event handler, if the current state is "published", then skip the push to edit state and stay in published (like it does if you hit save in any other state), but still with versioning applied. As I mentioned, I can't do this from OnBeforeUpdate() in the TreeNodeHandler because the doc has already been pushed into edit state.

So my question again is; Where is the core save handler so I can see if I can modify it to suit my needs?

User avatar
Member
Member
brien-anca - 7/25/2011 4:48:26 PM
   
RE:Overriding automatic return to Edit workflow state
Found it: \CMSModules\Content\CMSDesk\Edit\Edit.aspx.cs::SaveDocument()

User avatar
Member
Member
brien-anca - 7/25/2011 6:40:26 PM
   
RE:Overriding automatic return to Edit workflow state
OK. Edit.aspx.cs::SaveDocument() doesn't work because state is changed in CheckOut() operation. I did however, get the TreeNodeHandler to automatically push the doc back through the workflow.
public override void OnAfterUpdate(object treeNodeObj, object tree)
{
TreeNode node = (TreeNode)treeNodeObj;
WorkflowManager wm = new WorkflowManager((TreeProvider)tree);
WorkflowInfo wi = wm.GetNodeWorkflow(node);

if (wi != null)
{
// Document is using workflow
WorkflowStepInfo step = wm.GetStepInfo(node);
if (step.StepName.ToLower() == "edit"
&& node.IsPublished
&& node.NodeClassName == "ANCA.Article")
{
while (step != null && step.StepName.ToLower() != "published")
{
step = wm.MoveToNextStep(node, "Ignore workflow: Minor change to published article");
}
}
}
}

All working OK, except that the edit page needs a refresh after the event because it displays workflow state = Edit. Any way to inject a page refresh from the event handler?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 7/26/2011 2:41:10 AM
   
RE:Overriding automatic return to Edit workflow state
Hi,

If just the save button is accidentally hit, new workflow is started but the previous published version (which is in fact the same) is still displayed. Moving an image = its a change and the idea of workflow is to track any change.

In the event handler you will need to do some redirect or postback on the entire frame of the edit mode to refresh the workflow information in the frame. E.g. in FireFox you can get the current frame information - you will do the redirect to that frame and just add the query string parameters dynamically according to the current document so the editor is not "redirected" to the root every time.

Best regards,
Juraj Ondrus