Thursday, March 31, 2016

SharePoint Workflow Unique Email for Reassign and Change Request



One of the requirements I worked on recently required different emails(body of the email) to be sent and also the people who has to be cc'ed were different depending on what is selected. For example if the user selects "Reassign" an email has to sent to the reassigned person & CC his manager. If "Change Request" is selected email has to be sent with different text saying its a change request(I renamed it to "More Information" in my case).


Couple of blogs suggested to use Task Name property to see if it has(contains) "change request" word etc. But I wanted more flexibility in my solution and also some of the properties I wanted to set in my workflow were "Task Name" and "Due Date".


So after several testing and research below is my approach. This is using SharePoint 2010 workflow. Doesn't work in SharePoint 2013 workflow.


1. Open your designer, connect to site and click on "Workflows" from left navigation. Select the list workflow and click on the list to which you want to attach the workflow. Give a name to the workflow.






2.Inside your workflow add a "Start Custom Task Process", provide "these users" with the user names to whom you want to assign a task to. Then click on "Task(1)"

3. In "Task Form Fields" click on "New" and create a new field. In my case its WOStatus(type string) as shown below.


3. In "Settings" section check the box for "Reassign" and "Change Request".

4.  Publish your workflow once so that a task form is created.

5. Open your task form(InfoPath form).Now we'll have to set buttons with value. I mean click on "PAGE DESIGN" tab and from the "view" drop down click on "ReassignTask". Click on the "Send" button and from "PROPERTIES" tab click "Manage Rules". Here we are setting the WOStatus field to "Reassign" using some InfoPath rules. In a few minutes you will see why and where we can use this.

6. Similarly go to "Change Request" view. Click on the "Send" button and set the value for "WOStatus" as "Change Request".

7. Publish the workflow.

8. Now go inside the workflow by clicking on "Task(1)" and select "Change the behavior of a single task" as shown below.








9. Here since its Custom Task process, you will see all the sections are blank and each section is self explanatory by the one line description in the beginning.

10. The first step here is interesting as we'll be going to "When a Task Completes" section first. Because the values we set in the InfoPath will be lost after this step. So we will use a workflow variable to capture the value which is set by either "Reassign" or "Change Request".

11. Now we' can set our "Task Name" in "Before a Task is Assigned" section. (This is optional. I did this as I wanted my task name to be unique depending on whether its a reassign task or change request or initial task assignment.).

12. Now the actual part - to send the different emails depending on what is selected. Same as above to set the Task Name, Use the WOStatus to send the emails as shown below


There could be other ways to do this. But I found this method to be more flexible in setting the fields like task name, due dates(one of my requirements was to set different due dates. For example: For :"More Information"(Change Request) only 2 days has to be given if Reassign or initial task assignment 5 days)etc.



No comments:

Post a Comment