Tuesday 3 September 2013

Setting Workflow Status to Custom Values

If you consider workflow in SharePoint 2010,it will have certain default status such as In Progress,Completed,Failed on Start,Completed,etc..

but in case if we want custom values for the workflow that would enhance the look of the workflow status to the end user in more convenient way.

Steps Involved:

Note: I'm using Sequential Workflow,This can be used for state machine workflow also.
  1. Create a sequential workflow and select the type as List Workflow,
  2. So the Project explorer will look like,

    3. Edit the Element.xml file and add  the below custom tags just above the ending “Metadata” node,

    <ExtendedStatusColumnValues>
    <StatusColumnValue>Pending</StatusColumnValue>
    <StatusColumnValue>Approved</StatusColumnValue>
    <StatusColumnValue>Rejected</StatusColumnValue>
    </ExtendedStatusColumnValues>
    4. Let the logic in .cs file be as it is,now add a SetState activity form the toolbox and name it as setState1(any name you prefer) and this must be placed as the last activity in the workflow,then only it will work based on logic provided in all the other states located above.
    5.In the propeties of setstate activity give a name for MethodInvoking property,let it be "setState1_MethodInvoking"

    6. The integer value of the MAX is 15. From 0 to 14, the numbers are reserved for default values like InProgress, completed, error occurred etc. In Element.xml, the value of the first custom value will be 15 and then it will keep on increasing by 1. 
     So the values represented will be like,
    SPworkflowStatus.Max------>Pending
    SPworkflowStatus.Max+1------>Approved
    SPworkflowStatus.Max+2------>Rejected

    7. Build and Deploy to enjoy the result.



No comments:

Post a Comment