programming4us
programming4us
WEBSITE

Sharepoint 2010 : Creating a Workflow Using Visual Studio 2010 - Using the Visual Studio Workflow Designer (part 2)

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
SetStateActivity and CorrelationTokens

Moving onto the setState1 activity, we can see that the CorrelationToken property is invalid. CorrelationTokens are an important aspect of WF workflows and are used to determine the scope of the activity. A CorrelationToken is simply a text value that is used to group activities and, more importantly, the properties that they use. If a workflow has a property named foo, for example, when a workflow activity with a correlation token of token A writes to the foo property, other workflow actions with a correlation token of token A will be able to read the value. However, if a workflow action with a correlation token of token B writes to the property, the actions with a token of token A will still see the original value, whereas actions with token B will see the new value. In effect, every property is actually an array with the correlation token being used as an indexer. When it comes to SharePoint workflows, this is particularly relevant when using Task activities.

Set the CorrelationToken for setState1 to workflowToken with an OwnerActivityName of External_Calculation.

Adding Custom Status Values to SharePoint

Although the configuration of the setState activity is now valid, it doesn’t quite do what we want it to. When a workflow is added to a list item in SharePoint, a new column is added to the appropriate list that shows the current state of the workflow. The setState activity allows us to specify the value that should appear in this list. In our case, we want to show the text Awaiting Calculation Result.

Before we can display a custom value for workflow status, we need to let SharePoint know what our new value is. Workflow states are stored in SharePoint in a similar format to lookup values, so each state needs an ID and a text value. To add new states, we need only the text value, since SharePoint will automatically generate a new ID.

We can add the text for the new state in the Elements.xml file that exists under our External Calculation workflow in the Solution Explorer pane. Add an ExtendedStatusColumnValues element to the MetaData element, as shown:

<MetaData>
<AssociationCategories>List</AssociationCategories>
<StatusPageUrl>_layouts/WrkStat.aspx</StatusPageUrl>
<ExtendedStatusColumnValues>
<StatusColumnValue>Awaiting Calculation Result</StatusColumnValue>
</ExtendedStatusColumnValues>
</MetaData>

With the text value for our new status added, we can now configure our setState activity to use it. Unfortunately, it’s not quite as simple as that though. SetState expects the ID of our new state, and since this will be generated by SharePoint when our workflow is installed, we don’t currently have a reference to the ID value. We can calculate the ID for our new state simply by adding one to the ID of the last state that SharePoint defines internally.

  1. Right-click the workflow designer and then select View Code to see the code behind for our workflow. Add the following field:

    public int AwaitingCalculationState = ((int) SPWorkflowStatus.Max);

    SPWorkflowStatus is an enumeration of the workflow states that SharePoint provides by default. Our new extended status column value will be assigned the next ID in the sequence, which we can retrieve using the SPWorkflowStatus.Max value. If we wanted to add more than one additional state, we could use SPWorkflowStatus.Max +1, SPWorkflowStatus.Max+2, and so on, to determine the IDs for subsequent states.

  2. We can now bind the State property of our SetState activity to our new AwaitingCalculationState field.

HandleExternalActivity

The next activity to configure is handleExternalEventActivity1. This activity listens for an event from a pluggable workflow service. It’s configured in much the same way as callExternalMethodActivity1.

  1. Set the InterfaceType to IExternalCalculationService, and then select CalculationComplete from the EventName drop-down.

  2. Since this is an event, we don’t need to specify any parameters. Although, since we’re interested in the CalculationResultArgs parameter that is passed with the event, we can bind this value to a local variable using the e property. Click the ellipsis to show the Bind dialog. This time, select the Bind To New Member tab and then add a new property with the name CalculationCompleteArgs, as shown. This binding will store the values passed with the event in a local variable called CalculationCompleteArgs that we’ll be able to use in subsequent workflow activities.

LogToHistoryListActivity

We’ve now configured all the mandatory properties for our workflow. Before we deploy, we need to make one additional change. The logToHistoryListActivity1 action is not set up to log anything useful to the workflow history list. Since we want it to pick up the calculation result, we need to set a few properties.

  1. For HistoryOutcome, type Calculation Result.

  2. Using the Bind dialog, bind the HistoryDescription property to CalculationCompleteArgs.Result, as shown:

CodeActivity

The CodeActivity can be used to execute arbitrary code within the workflow engine. Our workflow requires that, as a result of the external calculation process, the Environmental Compliance flag is set to true or false. For the purposes of our demonstration, we’ll assume that our organization manufactures only environmentally friendly products and that the result of the calculation always indicates compliance.

  1. To configure the CodeActivity for the ExecuteCode property, enter UpdateFlag.

  2. Press enter, and the designer switches to code-behind view and a new method is automatically created for UpdateFlag. Add the following code:

    private void UpdateFlag(object sender, EventArgs e)
    {
    workflowProperties.Item["Environmental Compliance"] = true;
    workflowProperties.Item.Update();
    }
Other  
  •  Sharepoint 2010 : Creating a Pluggable Workflow Service (part 6) - Calling a SharePoint-Hosted WCF Service
  •  Sharepoint 2010 : Creating a Pluggable Workflow Service (part 5) - Calling a WCF Service, Receiving WCF Messages , Raising Events in a Workflow Service, Configuring Pluggable Workflow Services
  •  Sharepoint 2010 : Creating a Pluggable Workflow Service (part 4) - Using the ExternalDataExchange Attribute, Deriving from SPWorkflowExternalDataExchangeService
  •  Sharepoint 2010 : Creating a Pluggable Workflow Service (part 3) - Hosting an .svc File in SharePoint, Token Replacement in Visual Studio , Adding WCF Service Configuration to SharePoint
  •  Sharepoint 2010 : Creating a Pluggable Workflow Service (part 2) - Add a SharePoint-Hosted WCF Service
  •  Sharepoint 2010 : Creating a Pluggable Workflow Service (part 1) - Create a Windows Forms Client Hosting a WCF Service
  •  PowerShell for SharePoint 2013 : Word Automation Services - Disable Word 97–2003 Document Scanning , Disable Embedded Fonts in Conversions
  •  PowerShell for SharePoint 2013 : Word Automation Services - Modify Job Monitoring, Modify Conversion Timeouts
  •  PowerShell for SharePoint 2013 : Word Automation Services - Configure Supported Document Formats for Conversion, Modify Database Information
  •  PowerShell for SharePoint 2013 : Word Automation Services - Configure the Conversion Processes, Configure Conversion Throughput
  •  
    Top 10
    Free Mobile And Desktop Apps For Accessing Restricted Websites
    MASERATI QUATTROPORTE; DIESEL : Lure of Italian limos
    TOYOTA CAMRY 2; 2.5 : Camry now more comely
    KIA SORENTO 2.2CRDi : Fuel-sipping slugger
    How To Setup, Password Protect & Encrypt Wireless Internet Connection
    Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
    Backup & Restore Game Progress From Any Game With SaveGameProgress
    Generate A Facebook Timeline Cover Using A Free App
    New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
    SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
    - Messages forwarded by Outlook rule go nowhere
    - Create and Deploy Windows 7 Image
    - How do I check to see if my exchange 2003 is an open relay? (not using a open relay tester tool online, but on the console)
    - Creating and using an unencrypted cookie in ASP.NET
    - Directories
    - Poor Performance on Sharepoint 2010 Server
    - SBS 2008 ~ The e-mail alias already exists...
    - Public to Private IP - DNS Changes
    - Send Email from Winform application
    - How to create a .mdb file from ms sql server database.......
    programming4us programming4us
    programming4us
     
     
    programming4us