Guides and Tutorials

Create a button that triggers the task assignment

Updated: October 16, 2020

Now that we have a new permission that can be used in workspaces, we will leverage it for our validation logic: we will create a button that will assign a task to people having the "spellingValidation" permission. Only administrators of the workspace can modify the access rights. This means that it is the workspace administrator who decides of the assignments rules, which is more restrictive than the default behavior in Nuxeo DM (the user chooses himself all the participants).

To make this happen, we will leverage the Create Task operation.

To add the "request" button:

  1. Right-click on the User actions item of Studio tree, and click New Action Feature.
  2. Fill in :
  3. Click the button OK.
  4. In the "Action Enablement" part of the action definition form, enable the button:
    • only for documents of type File,
    • and for users who have at least the Write permission.
  5. Click on the create link at the bottom of the page, to create the corresponding automation chain.
  6. Give it a name, for instance RequestForValidationChain.
  7. Compose this automation chain, see below for the detail. Note the Services > Create task operation, whose goal is to assign the task, and to record what operation chain will be called when the task will be validated (and the one call if rejected too).
  8. Save your chain.

How to have the UI options in the automation chains panel.

First you have to define a user action, then, go to the bottom of the option page to the section « action execution » and click on the link Create. You will be redirected to the automation chains panel, but you will have the UI options available.

The **RequestForValidationChain** chain parameters

Operation

Parameter 1

parameter 2

parameter 3

parameter 4

parameter 5

parameter 6

parameter 7

1

Fetch > Context Document

 

 

 

 

 

 

 

2

Users Interface > Add Info Message

message: The workflow has been Started

 

 

 

 

 

 

3

Users and Groups > Get Users and Groups

permission: validationWorkflow_validation

variable name: assignees

 

Prefix Identifier: True

 

 

 

4

Users and Groups > Get Principal Emails

permission: validationWorkflow_validation

variable name: groupEmails

 

 

 

 

 

5

Execution Context > Set Context Variable

name: UserLastName

value: @{CurrentUser.LastName}

 

 

 

 

 

6

Execution Context > Set Context Variable

name: UserFirstName

value: @{CurrentUser.FirstName}

 

 

 

 

 

7

Users and Groups > Login As

name: Administrator

 

 

 

 

 

 

8

Services > Create task

Task name: Validation: @{Document.name}

Due date: @{CurrentDate.days(7).date()}

Directive: Enter a Directive

Comment: Enter a comment

accept operation chain: validationWorkflow_validate

reject operation chain: validationWorkflow_rejected

variable name for actors prefixed ids: assignees

9

Users and Groups > Logout

 

 

 

 

 

 

 

10

Notification > Send E-Mail

from: @{CurrentUser.email}

message: Click on the icon to select your mail template validationWorkflow_mail.

Subject: Document Validation: @{Document.name}

To: @{groupEmails})}

As HTML: checked

 

viewID: view_documents

In this sample, when the user validates, we call the validation chain and everything stops. We could also have decided to run another "Create Task" in that ValidationChain, so as to create the task for next step validation, and continue all along the life cycle of the document if necessary.

If you want to allow the user to launch a workflow without leaving him the rights to approve or reject the task, you can login as an Administrator using the « Users & Groups > Login As » block just before the « Services > Create task » block. Like that, the task will be created as an administrator and the current used won’t have the basics approve / reject rights on the task. Don’t forget to logout after that.