Friday, May 3, 2013

Developing Initiation Form on Sharepoint Workflows

Have you ever wondered what's the use of Initiation Forms on Sharepoint? Have you ever thought of creating a list item based on an item on another list? Do you want to extend the 2 buttons in Manual Workflow Initiation to have input forms? Well that’s the use of the Initiation Forms and I will run you though a sample that will work for you.

So what is an Initiation form? It's simply a page that is presented when you start a workflow manually, the page where you see two buttons for “Start” and “Cancel”. By default, you have those buttons but you can extend this page by adding form fields and use the value on those as variables that you can consume for your workflow process.

So let's start with a sample, let's say you have the requirement to have an Office Supply list where your team can place an order on a specific item and that invokes a workflow on the back, making a task list grabbing important details like Name of requester, quantity and the Item requested. Here are the steps to achieve it.
  1. Create an “Office Supplies” List:
  2. Now using Sharepoint Designer, go to your list and create a workflow.
  3. Name your workflow, I called it “Supply Request Workflow”
  4. Now Save and Publish your workflow and make sure it created a Task List and History List:
  5. Double check if you have the Task List by going to your Sharepoint instance:
  6. Now update that task list to cater to the following new fields: Item Requested, Quantity and Requested By.
  7. Back to Sharepoint Designer and edit your workflow again:
  8. Now create an Initiation Form by clicking the Initiation Form Parameters:
  9. Now add the field, this is the field that will populate your Task List as well on step 6, so create the same fields and its format you have on the said step.
  10. Once done, it is time for you to set up an Action on Step 1, and we need to create a “Create List Item” action:
  11. Now choose the property “this list”.
  12. Now choose the “Association: Task List”:
  13. Modify the Value sent to those fields:
  14. For example, in the Title Field (“of the Task List”), you want to use the Current Item which is the “Office Supply List” Name.
  15. You can add more strings of your choice if you want, so since this is a new request we make the title “New Item Requested : Your Item”.
  16. Now for other fields like Quantity, you can grab it from the initiation form you created in Step 8. To do that, just choose “Workflow Variables and Parameters” in Data Source and you will see the fields you created on the “Field from source”.
  17. Once all values are properly assigned, click OK.
  18. Now Save and Publish again.
  19. Now usually manual initiation workflow starts by hitting the Workflows Button, then choosing the appropriate workflow to run. To make it a bit user-friendly, I guess we will have to create a button on the Display Form Ribbon of an item. Do that by clicking Custom Action and choose “Display Form Ribbon”.
  20. Now name your button, I called it Request now. And set it to initiate your “Supply Request Workflow”.
  21. Add your icons. Then you are done.
  22. Open now a list item on “Office Supplies” list, then you will see your “Request Now” button. Click that.
  23. Now you see your “Supply Request Workflow” with the input forms you had defined.
  24. Click start to initiate the request, and you will see it on the “Task List”
  25. With the fields populated as configured.

No comments:

Post a Comment