Navigate Up
Sign In
Supporters of Developer
Web

Apply Custom Values to Visual Studio Workflow Statuses

Item is currently unrated. Press SHIFT+ENTER to rate this item.1 star selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+ESCAPE to leave rating submit mode.2 stars selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.3 stars selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.4 stars selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.5 stars selected. Press SHIFT+ENTER to submit. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.

You may also be interested in: SharePoint App Development by mindfiresolutions

 

Editor's note: Contributor Nicholas Holloway is an Application Developer. Follow him @nholloway4

Today I will show you how to apply Custom Values to Workflow Statuses. We all know that improving business processes is an essential part to capitalizing on the ROI for SharePoint. By this, SharePoint Workflows are used to automate and streamline these processes. Workflow has some built in values like, “In Progress”, “Failed on Start”, Error Occurred”, etc. All of these are OOTB statuses that are provided, but what if we wanted custom values for the workflow. A custom value that would specifically show what stage in the process it is currently on.

We are able to set custom values for workflows, but this can only be achieved in Visual Studio. Subsequently, OOTB or SharePoint Designer workflows cannot be changed.

Creating these custom values can be done in Visual Studio Sequential or State Machine Workflows.

First we must open the Elements.xml file and place the code below:

2012-10-09-VSWorkflowStatuses-01.png


<ExtendedStatusColumnValues>
        <StatusColumnValue>Pending</StatusColumnValue>
        <StatusColumnValue>Stage 2</StatusColumnValue>
        <StatusColumnValue>Stage 3</StatusColumnValue>
        <StatusColumnValue>Stage 4</StatusColumnValue>
        <StatusColumnValue>Stage 5</StatusColumnValue>
        <StatusColumnValue>Completed</StatusColumnValue>
        </ExtendedStatusColumnValues>

The code should be entered just above the ending “Metadata” xml node like so

2012-10-09-VSWorkflowStatuses-02.png

After this is done, proceed by going to the Workflow Design view and add a “Set State” activity. Be careful as to add the “Set State” Activity in the “SharePoint Workflow” toolbar which sets the status of the state.

2012-10-09-VSWorkflowStatuses-03.png

The “Set State” activity in the Windows Workflow v3.0 is for setting the next state in the workflow.

Once you drag the "SetState" activity on the Designer page, right click on it and open its properties. Bind its "State" properties to a variable and select "field" while binding it. Select the correlation token as "WorkflowToken" as this activity does not belong to any task. Double click on the activity and it will promt you to enter some code:

Let us assume that your "SetState" activity name is "InitialState". When you double click on the "SetState" activity, insert the line below in the code window:


InitialState.State = (Int32)SPWorkflowStatus.MAX;

The integer value for MAX is 15. The values from 0 to 14 are reserved for internal and built-in values such as InProgress, Completed, Error Occurred etc. that I stated earlier. In the elements.xml, the value of the first custom value will be 15 (See above as we specified the first custom value as Pending). It will then keep on increasing by 1. For instance, if we want to assign the "Stage 2" value to the workflow then we will write the below line of code:


InitialState.State = (Int32)SPWorkflowStatus.MAX + 1;

The line above will assign the "Stage 2" custom value to the State variable and whenever the workflow reaches this state it will show the status "Stage 2". Similarly, we can write any number of custom values to our workflow. We have used only two custom values in the above elements.xml. If we want to use a third one then we will right it just below the "Stage 2" custom value like:


<ExtendedStatusColumnValues>
        <StatusColumnValue>Pending</StatusColumnValue>
        <StatusColumnValue>Stage 2</StatusColumnValue>
        <StatusColumnValue>Stage 3</StatusColumnValue>
        <StatusColumnValue>Stage 4</StatusColumnValue>
        <StatusColumnValue>Stage 5</StatusColumnValue>
        <StatusColumnValue>Completed</StatusColumnValue>
        </ExtendedStatusColumnValues>

The value of "Stage 3" status will be assigned as follows:


InitialState.State = (Int32)SPWorkflowStatus.MAX + 2;

This pattern will continue until you have finished all statuses which is dependent upon the number of states comprised in your workflow.

If you change your workflow.xml file by changing the workflow custom values then deploy it again and run IISRESET, you'll see the changes in SharePoint List as to when the workflow will run.

After completing the tasks at hand we can set our own custom value fields to Visual Studio Workflows.

Categories: Visual Studio; dev; Workflow; MOSS; WSS; 2007; 2010

Comments

Sultan Khan

Be precise

Be precise as to increase the “Set Commonwealth” Work in the “SharePoint Workflow” toolbar custom essay writing service which rigids the status of the predicament.

Posted 26-Oct-2013 by Sultan Khan
Fake Oakleys

Oakley Outlet

Oakley Sunglasses Cheap has first-class R & D design team, advanced production equipment and technical personnel, coupled with professional quality control, so that all glasses from R & D, design to production, and most of the new jobs are always both physical world patents. Imported high quality Cheap Oakley Antix Sunglasses Sale polarized lenses, which greatly effect cuts glare, eliminate reflected light, scattered light, depending on the material softer and clear. Cheap Oakley Hijinx Sunglasses Sale lenses not only have the most effective elimination of UVA, UVB harmful ultraviolet rays and reduce glare Blu-ray transmission, but also to block the glare, has at least the advantage of changing the color of the object itself, watching the scene more real and natural. Cheap Oakleys sunglasses polarized lens angle and curvature through professional design and processing, the wearer will not have the feeling of the scene distortion and dizziness. Meanwhile lens has a light, easily deformed, broken advantages, wearing relaxed and comfortable.

Posted 03-Nov-2013 by Fake Oakleys
Brucewayne

Thanks a lot!!

I never knew that we can set custom values for workflows. Thanks a lot for this valuable info and detailed demonstration. You spared me a lot of time. Apart from Visual studios is there any other software which can set custom values to workflows? windows support scam

Posted 28-Feb-2014 by Brucewayne
kata kata mutiara

india

I never knew that we can set custom values for workflows. Thanks a lot for this valuable info and detailed demonstration. You spared me a lot of time. Apart from Visual studios is there any other software which can set custom values to workflows? cara agar cepat hamil,kata kata lucu, kata kata mutiara,kata kata romantis kata kata indah,hamil

Posted 09-Mar-2014 by kata kata mutiara
workflows

spared

Thanks a lot for this valuable info and detailed demonstration. You spared me a lot of time. Apart from Visual studios is there any other software which can set custom values to workflows. Seychelles Company formation

Posted 12-Mar-2014 by workflows

Notify me of comments to this article

E-mail:
   

Add Comment

Title:

 
Comment:
Email:

   


Name:

 
Url: