Monday, January 14, 2008

Custom Workflow using SharePoint Designer

This comes from: http://metahat.blogspot.com/2006/12/1.html

1.1Scenario:

  • Author creates document and submits the approval request to the

  • Reviewer approves/rejects the document.

    • In case of approval email is sent to author notifying approval

    • In case of rejection email is sent to author notifying rejection

1.2Implementation:

  • Create an sharepoint list with approval enabled



  • Open sharepoint designer 2007
  • Open the desired site for workflow as shown below :
    • Click File ->Open Site
    • Enter the url of the desired site in site name section and press “Open”
    • This will open the site
  • Creating new workflow
    • Click File -> New
    • The “New “ Dialog box will pop up
    • Select “SharePoint Content” tab
    • Select workflow from the list box “Blank workflow”
    • Assign appropriate name to workflow in my case its “Approval workflow”
    • Select the list in sharepoint list to which this workflow should be associated
    • Select the start condition of the workflow
      • Start when item is created
      • Start when iten is changed
      • Manual workflow start up

    • Before we start we will go forward and define some initiation workflow variables .
    • Click on the initiation button
      • Define a variable named “workflowstatus” and set the default value as “notstarted”

1.2.1STEP 1

  • Lets start defining the workflow
    • First define a step name “To Approver”
    • Click conditions button and you will get an drop down


    • Select “Compare any data source” you will get option as shown in figure
    • click on the “value” you will get an input box with an eclipse button like this



    • Click on that “fx” eclipse button
    • You will get dialog box like this with “current item” as default selection
    • change the selection to”Source: workflow data” and in the field section select :Initiation :workflowstatus”

    • Click Ok
    • Now select the “value” field after “equal “ and in the input box fill “notstarted”


    • No we are ready with our condition with says “ If “workflowstatus” variable is equal to “notstarted” then execute the defined action
    • Lets Go forward and put process in our action section


    • select “Set workflow variable”
    • Set the values as shown in fig below



    • Now we have set the workflow variable” workflowstatus”to started
    • Lets send E-Mail to the Reviewer for approval request
    • From the actions Menu select send an EMAIL



      • click on “this message” which will eventually pop up a self descriptive dialog box



      • Fill all the appropriate fields for EMAIL and Email is set
        • To : “Reviewer Email ID”
        • Subject

        • Body
    • After email to reviewer we have to make sure that our workflow waits for “Approval/Rejection ” from the Reviewer
    • In order to achieve a “WAIT” we have to add one more action

      • So click on the actions and select “Wait for field change in current item”
      • Assign values and make condition as shown below

Ie Wait till the “Approval status “ is not either “Approved/Rejected”
  • We are done with our first step where the author has requested an approval and reviewer has received mail of approval request

1.2.2STEP 2

  • In this step we have to take care of 2 conditions “Approved /Rejected “
  • To define seconf step click “Add workflow step “on eight pane of workflow designer
  • The Second step would look like this


  • So define 2 conditions “If approved “ and If Reject “
  • The branching of condition can be achieved using the drop down of activity


  • This will take care of the second step
  • Once the email is send stop the workflow by selecting “stop workflow” from the Action menu , this make stop the workflow and make the workflow status to complete

NOTE: Always make sure to stop workflow in all the implementation, in case its missed the workflow will still be alive in the system and that might lead to server performance degradation

3 comments:

  1. This was a very helpful blog shared
    Thank you very much

    ReplyDelete
  2. When I add a new item to the list as a "Full Control" user, the workflow kicks off, the supervisor is emailed and the document is approved fine. But when I add a new item as a "Contributor" user, the workflow bombs with an "Access Denied" error in the workflow history. According to the SharePoint permissions screens, "Contributor" users don't have permission to approve content. How can I change the context under which the workflow runs in order to allow it to approve the document uploaded by a "Contributor"?

    Thanks,

    ReplyDelete
  3. Would you not create an approvers group in addition to the contributors group, to approve items submitted by contributors?

    You can add in an approval group to the workflow participants in the workflow settings.

    ReplyDelete