In my last blog post I gave a quick introduction to Nintex Workflow for SharePoint and showed you how to create a very basic workflow with a custom Start Form. I based the fields that are being collected in the Start Form around the idea of a kind of approval workflow that would have 3 types of Approvals that I named Content Approval, Format Approval and Grammar Approval. These approval types could be anything, the idea is just to show that you may have approvals/tasks that are very similar but you would like a few minor differences like with the wording of the Task Description. In order to accomplish this without recreating or copying the same set of Actions multiple times I am going to show you how to create a User Defined Action. A User Defined Action is created in a very similar way to the workflow itself but it allows you to use that set of Actions multiple times in your workflow, or in multiple workflows for that matter, as if it was one action. One of the big advantages to doing this is that if later you need to make a change to that part of the workflow, you can just change the User Defined Action so you don’t have to make the change multiple times.
Now that you get the idea let’s get started. Click on Site Actions. Select Nintex Workflow 2010 and then select Manage User Defined Actions.
Click Create. You will notice that the screen looks the same as when we created the workflow in the previous post.
Go into UDA Settings from the ribbon and enter a Title and Description and optionally change the Category. Click Parameters.
Click New. Enter “ProjectManager” for Name, “Input” for Direction, “Text” as the Type, enter a Description if you want and select Required. Even though you are passing in a person it will accept it as text. Click OK. Click New and create an Input Parameter for “ApprovalText”, “ApprovalType” and “Approver” all with Type of Text. When you are done the User Defined Action Parameter screen should look like this.
Click Close. Click Save on the User Defined Action Settings Screen. Now we are ready to start building the User Defined Action. The process for this is the same as building a workflow. You either select an Action from the left and drag it to the spot you want it or right-click on the spot you want an Action, select Insert Action and select the Action you want. You can then configure the action if necessary.
The first Action we will add will be for a task. There are a few different Actions I could use for this but I am going to use the Flexi task because just like it sounds, it’s a bit more flexible. Right click on the open spot in the Custom Action screen, hover over Insert Action, hover over User interaction and select Assign Flexi task.
Just like in the Workflow you will notice that the Action has an exclamation point indicating it needs to be configured. You will also notice that it has created 2 braches, Approve and Reject. With a Flexi task this can be customized to have different labels and even to add additional outcomes.
Click on the drop down arrow on the Action and select Configure. In the Configure Action screen you can specify who to assign the task to, enter a description of the task, customize the outcomes, etc. You can also customize the task notification that gets sent to the assignee.
To start with we will specify the Assignee by clicking the lookup icon next to the Assignees field. At the bottom of the Select People and Groups dialog expand the “Lookup” section and then scroll down to the Workflow Variables group and click on Approver, click Add and then OK.
This will cause the task to be assigned to the Approver that we setup previously as an input parameter into the User Defined Action. Now we can enter a Task Description. Since we also created an input parameter for Approval Text we will select that for the Description by clicking the Insert Reference button, selecting the Parameters tab, double-clicking ApprovalText and clicking OK. At this point let’s add an additional Outcome. Click Add outcome. Enter “Request Changes” for the name and click OK.
For behavior I am going to just leave it as “First response applies”. The Behavior selection is designed for instances where there are multiple assignees. You can decide if the Outcome is decided by the First response, Majority, or All assignees agreeing. For the purposes of this I am not storing the outcome or outcome achieved. Let’s change the Task Name though. If you remember we created an input parameter of Approval Type. Let’s set the Task name by clearing the default text and then clicking the lookup button next to the field. Click into the “Dynamic text to insert” area at the bottom and type “Review ” (leaving a space at the end). Select the Parameters tab and double-click on ApprovalType and click OK.
I am leaving the rest of the options at their default values so your “Configure Actions” dialog should now look like this.
Now we can customize the notification by clicking the “Task Notification” button in the ribbon. Add the Project Manager to the CC field by click the lookup button next to that field, expanding the Lookup section, scrolling to the Workflow Variables group and adding ProjectManager. Now we can set the Subject to the same value as the Task Name by clearing the default text, clicking the lookup icon, typing “Review ” in the “Dynamic text to insert” area, selecting the Parameters tab, double-clicking ApprovalType and clicking OK just like we did previously. We can now also add the ApprovalText into the notification text. Click on the end of the first line and hit “Enter” twice to add a couple extra line. Put your cursor on the second line and click the “Insert Reference” button. Click on the Parameters tab and double-click ApprovalText and click OK. Your Task Notification should now look like this.
Click on the General tab at the top and click Save. Notice the exclamation point is gone in the Action. Also notice that there is a third branch called “Request Changes”. We are not going to do anything with that branch now but it will be used in another blog post when I discuss looping. Right now all I am going to add is some logging in the Reject and Approve branches. Add the “Log in history list Action” from the Operations group into the “Reject” branch. Click the drop down and select Configure. Click Insert Reference. Go to the “Parameters” tab and double-click ApprovalType. In the Dynamic text to insert box add ” Rejected – ” after the text that was added. Then click the “Common” tab and double-click Approver Comments. Click OK.
Since the only difference between what I want to log for an Approve and a Reject is one word let’s copy by clicking on the drop down icon for the new Log in history list Action under Reject and selecting “Copy”.
Right click on the open space in the Approve branch and select “Paste”. Then Configure the “Log in history list” Action in the Approve branch and change the word Rejected to Approved. Click Save.
We now have a complete User Defined Action so click Publish in the ribbon, add any Change Comments you would like and click Submit. Click Close in the ribbon.
To summarize, in this post we learned how to create a User Defined Action, add and configure the Flexi task Action, customize the notification and add outcomes. In my next blog post I will show you how to add the User Defined Action to the workflow and how to run Actions in parallel.