Basic workflow problem

Stefan Lorenz asked on June 29, 2014 09:08

Hi,

here's my scenario: I defined a basic workflow with one additional step ("Approve Doc") between "Edit" and "Published". The workflow is attached to a document type. On my live site users can create documents of that type (using a modified version of the "User Contribution" webpart). They can't edit or delete, just create new documents.

When doing so, the documents are automatically set to the first workflow step "Edit", though I need them in the "Approve" step in order to let my editors see the doc in "Pending documents" and review/publish them.

The following ideas come to my mind: 1.) Set the workflow step in the webpart: I found no way to get the NodeID of the new doc in editForm_OnAfterSave()) 2.) Advance the workflow using a global event handler: tried that as well, using DocumentEvents.Insert.After event, but that didn't work either. WorkflowManager.GetNextStepInfo returns only "Archived" as a valid next step, though there should be "Approve" and "Published" as well.

In general I would be fine without the custom step, but I can't assign roles/users to the default steps, so I guess the custom step is mandatory then.

So I'm stuck here. Anyone knows a way out?

Best regards, Stefan

Correct Answer

Stefan Lorenz answered on July 22, 2014 09:01

Thanks to the support it's working now: The code was correct, but I needed to set the workflow in the Update.After event instead of Insert.After.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Yehuda Lando answered on June 29, 2014 17:38

I'm doing the same thing. I have a custom web part, but I don't see why you won't be able to use it in editForm_OnAfterSave or the global event handler.

This is my code:

if (node.WorkflowManager.GetNodeWorkflowScope(node) != null)
        node.WorkflowManager.MoveToNextStep(node, null, WorkflowTransitionTypeEnum.Automatic);
0 votesVote for this answer Mark as a Correct answer

Stefan Lorenz answered on June 30, 2014 03:19

I used exactly that code in the global event handler and it debug stepped through it without any errors, but that doesn't do anyting, the document stays in edit step...

0 votesVote for this answer Mark as a Correct answer

Stefan Lorenz answered on July 9, 2014 03:21

This problem is still unsolved. I followed the global handler (DocumentEvents.Insert.After) road and this is my code (the interesting parts):

var currentStep=e.Node.WorkflowStepName; // it's strange, but this results in "published"
var newStep=e.Node.MoveToNextStep(); // this results into "published" step as well.
e.Node.Update();

However, viewing the document in the Pages app shows it's still in the Edit step. I also tried the code from the previous post and some other variants, but all returning the same result. In general I ask me why e.Node.WorkflowStepName returns "published" though in Pages it shows "edit"?

Any ideas?

0 votesVote for this answer Mark as a Correct answer

Charles Matvchuk answered on April 16, 2015 03:01

What was the final solution for this ?

0 votesVote for this answer Mark as a Correct answer

Stefan Lorenz answered on April 16, 2015 08:28

As said above, the code was correct, but it needs to be executed in the Update.After event, not in Insert.After

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.