Advanced Workflow Step

Mohamad Ramadan asked on September 15, 2020 13:29

Hi,

I have the current scenario

  • I have a custom table called "Representative Type", loaded with predefined data as a lookup
  • and I have advanced workflow with a step called "Send To Representative" i need to enable the user to select the representative type before taking the action "Send To representative"

how to implement this scenario i can add a new field on the page and display this field on the page type, but this is not user friendly and not all pages will be sent to the representative as well

is there a way to enable the user to select the representative after choosing to send to representative action on an advanced workflow step, I need the user to be able to select a value from a dropdown menu (loads it's data from predefined custom Table) so

Recent Answers


Dmitry Bastron answered on September 15, 2020 16:02

Hi Mohamad,

I don't think that the customization you are asking for is possible to implement on 100%. The closest you can get to I think could be one of these solutions:

  • to use a user choice or automatic choice and manage the list of representatives as choices
  • write a custom workflow step that will be reading a representative field from page type (like you mentioned in your question)
0 votesVote for this answer Mark as a Correct answer

Mohamad Ramadan answered on September 15, 2020 16:33

Hi Dmitry

thanks for the reply, the list of representative types is unknown to me, the client can add one or many types later as he works, so I think the first option is not gonna help by anyway, am I right?

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on September 15, 2020 17:22

Yes, the first option is not applicable then. Regarding the second option, you can try the following workaround: for your page type field you can add visibility condition:

EditedObject.DocumentWorkflowStep.CodeName = "YourWorkflowStep"

When the admin will move the document to this step - this field will appear only then. However, making it required maybe a bit more difficult to do. If you simply mark the field as "required" it will not help as it doesn't stop you from moving document between workflow steps. It will require writing some global event handler, but I'm not 100% sure it will work in this particular case.

1 votesVote for this answer Mark as a Correct answer

Mohamad Ramadan answered on September 17, 2020 11:06 (last edited on September 17, 2020 11:08)

Hi Dmitry

I applied the second option where a page type now have the representative type as a drop-down list

I'm facing an issue now, where I need to ensure the editor user select a representative before choosing "send to a representative ", the editor user has other options like publish directly so not all documents need to be sent to a representative

I've tried to use the global workflow event Approve_After to cancel and throw an exception with a custom message but this doesn't help "a general error message is displayed and the document I think it's moving to the next step, then after the refresh, it return back to the editor step"

so how can I implement this, even if from another event like document.saveafter to force the user to select the representative and display a custom error message

https://imgur.com/nJtH7C5

Image Text

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on September 17, 2020 11:14

Hi Mohamad,

You'd need to do it inside before event (Document Update Before, or Workflow Approve Before). If you cancel in Before event, the actual action will be cancelled, in After event it's too late, the CMS has already written these changes in the database and can't un-do it.

0 votesVote for this answer Mark as a Correct answer

Mohamad Ramadan answered on September 17, 2020 12:32

ok great one last thing how to show a custom message like "please choose representative" on the info bar or as an exception on red, if you have an example or reference would be great

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on September 17, 2020 12:42

I believe this code should do the trick:

eventArgs.Cancel();
throw new Exception("Your custom error message");
0 votesVote for this answer Mark as a Correct answer

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