New features Please use http://kentico.uservoice.com as the primary place to submit your suggestions and allow others to vote for your ideas!
Version 5.x > New features > Workflow, choose step to go on rejection View modes: 
User avatar
Member
Member
jim.morrissey-asg - 4/11/2011 9:33:34 AM
   
Workflow, choose step to go on rejection
Something that I realized working with the workflow that would be nice, is that if there are multiple steps in a workflow and one was rejected that you could specify which step in the workflow it would go to after rejection. As of now I have about 3 steps in between Edit and Publish that if step 2 or 3 of those were to reject it I would like it to go back to Edit instead of back down the ladder and make each step in there reject it down to edit.

Thanks!

User avatar
Kentico Support
Kentico Support
kentico_radekm - 4/12/2011 6:34:20 AM
   
RE:Workflow, choose step to go on rejection
Hello.

This is possible in current solution via simple customization of \CMSModules\Content\Controls\EditMenu.ascx page. There is Reject button defined:

<cms:CMSButton ID="btnReject" runat="server" EnableViewState="false" OnClick="btnReject_Click" /> 


And you can manage what step is loaded in btnReject_Click method

You can find API example for managing documents under workflow on devnet.kentico.com/docs/devguide/a_complete_example.htm

Best Regards,
Radek Macalik

User avatar
Member
Member
libertybay - 8/8/2011 3:01:53 PM
   
RE:Workflow, choose step to go on rejection
I am attempting this very change. However, the btnReject_Click event in EditMenu.ascx.cs does not seem to fire unless I modify the EditMenu.js file to run LocalReject() like so:


function Reject(nodeId) {
if ((parent.frames[controlFrame] != null) && (parent.frames[controlFrame].Reject != null)) {
//parent.frames[controlFrame].Reject(nodeId);
LocalReject();
}
else {
LocalReject();
}
}


I'm unclear what side effects this will have.

What is your recommended implementation?

Thanks.

User avatar
Kentico Support
Kentico Support
kentico_radekm - 8/14/2011 10:05:43 PM
   
RE:Workflow, choose step to go on rejection
Hello.

Yes, you can use your approach. However, we would recommend you to use a custom workflow handler: http://devnet.kentico.com/docs/devguide/workflow_handler.htm. You can check a document or workflow step if a document is approved/rejected and move it to a different step like: http://devnet.kentico.com/docs/devguide/workflow_internals.htm.

Best Regards,
Radek Macalik

User avatar
Member
Member
VajdaS-asme - 4/12/2012 8:02:34 AM
   
RE:Workflow, choose step to go on rejection
LibertyBay is absolutely correct. The EditMenu.ascx.cs reject event handler does not get called. The EditMenu.js calls the EditPage Reject function and I have no idea how the document is set back to the previous step so I don't know how to customize it.

If we don't know how it is currently being done how will using a custom workflow handler help us. LibertyBay, Jim and myself all seem to want to do something similar so we would appreciate more detailed advice.

Thanks.

Steve

User avatar
Member
Member
VajdaS-asme - 4/10/2012 12:27:10 PM
   
RE:Workflow, choose step to go on rejection
Hi Radek:
http://devnet.kentico.com/docs/devguide/workflow_internals.htm doesn't return anything.

Can I add an additional control, like mentioned above, to only one workflow?

How do I return the rejected document to a specific role?

Thanks very much.


Steve

User avatar
Kentico Support
Kentico Support
kentico_radekm2 - 4/11/2012 6:43:17 PM
   
RE:Workflow, choose step to go on rejection
Hello.

Sorry for that link. You can find Workflow internals info at http://devnet.kentico.com/docs/devguide/workflow_api_overview.htm

There are also some API examples you could take an inspiration from. Regarding roles, you could take an advantage of this API.

Best Regards,
Radek Macalik

User avatar
Kentico Support
Kentico Support
kentico_radekm2 - 4/18/2012 12:46:01 AM
   
RE:Workflow, choose step to go on rejection
Hello.

I believe we already found the solution. Let me post it here for other users.

First thing you need to do is to add a new MenuItem button. You can do so in the ReloadMenu method (~\CMSModules\Content\Controls\EditMenu.ascx.cs) which I suppose you have done already.

It is worth to mention the JavascriptCommand property that should contain a name of your custom javascript method:

newItem2.JavascriptCommand = FunctionsPrefix + "RejectToEdit(" + nodeId + ");";


This method should be defined in the ~\CMSModules\Content\CMSDesk\Edit\EditMenu.js file:

function RejectToEdit(nodeId) {
if ((parent.frames[controlFrame] != null) && (parent.frames[controlFrame].RejectToEdit != null)) {
parent.frames[controlFrame].RejectToEdit(nodeId);
}
}


As you can see, another javascript method from the parent frame called RejectToEdit(nodeId) is called. This time, you need to define it in the following file: ~\CMSScripts\cmsedit.js

function RejectToEdit(nodeId) {
ClearToolbar();

if (window.frames['pageview'].RejectToEdit) {
window.frames['pageview'].RejectToEdit(nodeId);
}
}


At this point, you need to go to the ~\CMSModules\Content\CMSDesk\Edit\Edit.aspx.cs file and add a new button to the aspx markup:

<cms:CMSButton ID="btnRejectToEdit" runat="server" CssClass="HiddenButton" EnableViewState="false" OnClick="btnRejectToEdit_Click" />


This button will be hidden due to the assigned CssClass. In the code behind, you need to define the OnClick method that gets executed when the button has been clicked:

protected void btnRejectToEdit_Click(object sender, EventArgs e)
{
// Here goes your custom code
}


And now, last but not least, you need modify the OnInit method in the same file. At the end of the OnInit method, you can see the following code that registers another javascript methods that are required to fire OnClick handlers of the buttons (Save, Reject, etc.):

AddScript(
"function SaveDocument(nodeId, createAnother) { document.getElementById('hidAnother').value = createAnother; " + (confirmChanges ? "AllowSubmit(); " : "") + ClientScript.GetPostBackEventReference(btnSave, null) + "; } \n" +
"function Approve(nodeId) { SubmitAction(); " + ClientScript.GetPostBackEventReference(btnApprove, null) + "; } \n" +
"function Reject(nodeId) { SubmitAction(); " + ClientScript.GetPostBackEventReference(btnReject, null) + "; } \n" +
"function CheckIn(nodeId) { SubmitAction(); " + ClientScript.GetPostBackEventReference(btnCheckIn, null) + "; } \n" +
(confirmChanges ? "var confirmLeave='" + GetString("Content.ConfirmLeave") + "'; \n" : "")
);


You need to simply add a reference to your custom javascript RejectToEdit method and create a post back reference to your custom button btnRejectToEdit as demonstrated here:

"function RejectToEdit(nodeId){ SubmitAction(); " + ClientScript.GetPostBackEventReference(btnRejectToEdit, null) + "; } \n"


Best Regards,
Radek Macalik