.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Is there a way to check if workflow instance already exists for a particular productID in Workflow o

Posted By:      Posted Date: August 29, 2010    Points: 0   Category :WPF
I am using Visual Studio 2008 and .NET 3.5. I am trying to build a WF that is exposed as WCF hosted on IIS. This service is consumed by ASP.NET client. It is a very simple WF- receive info for new product "A"- send email to person 'Xyz' that new prodcut "A" is received- do some business process for product "A"- send out more notifications for product "A"Consider this scenario - - Client hits submit on asp.net page for prodcut "A"- new WF instance is created for product "A"- client can go back to the same page, edit some more info and hit save again. However, this time or for any subsequent "Saves",  I do not want to create a new WF instance for product "A".I can check to see if a WF instance exists for product "A" on the client side before calling the service operation. However, I want to see if there is a way to do this in WF or WorkflowServiceHost, as I don't want to add this logic to client. First acitvity in WF has to be receive activity with CanCreateInstance = true, so not sure how I can do this check in WF itself.Also, I have another stupid question, when using WF exposed as WCF service, do we have to implement all service operations using WF? What if I have some service operations that just involves checking some business logic? Do I implement this in a

View Complete Post

More Related Resource Links

Can I dehydrate the Workflow object as well as the instance?

Hiya All Can I dehydrate the workflow object (i.e. not an instanciation of it) into SQLServer?  I want to save all versions created of a workflow so that I can chose to instanciate the workflow from any of the previous versions if I need to. This is due to a compliancy issue - being able to reconstruct the data created by a previous version of a workflow to prove accuracy. ThanksMichelle x

System.InvalidOperationException: Instance operation is not valid on workflow runtime thread

Am getting the exception related in the title of this article when using the StateMachineWorkflowInstance object to arbitarily set state in my workflow code; and am unsure why.  The code follows below:   500     Protected Overrides Function Execute(ByVal executionContext As System.Workflow.ComponentModel.ActivityExecutionContext) As System.Workflow.ComponentModel.ActivityExecutionStatus   501    502    506         Dim smwi As StateMachineWorkflowInstance = New StateMachineWorkflowInstance(StaticWFRuntime.LocalRuntime, Me.WorkflowInstanceId)   511    512         'set workflow-wide database connection string   513         _connectionString = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString   518    519         Utility.LogEnabled()   520    521         Utility.FoaeaLogger.WriteEntry("Processing TracingApplication.Execute()....", EventLogEntryType.Information)   522         If StaticWFRuntime.LocalRuntime Is Nothing OrElse StaticWFRuntime.LocalRuntime.IsStarted = False Then   523             Utility.FoaeaLogger.WriteEntry("No static RuntimeService object exists!", EventLogEntryType.Warning)   524         End If   525    526         Return MyBase.Execute(executionContext)   527    528     End Function   796     Private Sub gotoState2_ExecuteCode(ByVal sender As System.Object, ByVal e As System.EventArgs)   797    798        

Workflow Instance ID field in MS Access

Hello, please help! When I open a SP list with MS Access (Action > Open with Access), the Workflow Instance ID field is available with no data.  How can I get this field to display so I can create queries within MS Access using joins/relationships?  Thank you!

Question about Workflow in Document Library with version control and check-in/out enabled



I use Sharepoint Foundation 2010 and have a workflow to set some metadata in a document with version control and check-in/check-out enabled (approval content is not enabled because anyone in the team can be a possible editor of the document).

My metadata is:

- a generated doc id with text+id (example P&D_1)

- a calculated status based in version: minor version = "on development" and major-version="published/approved"

I defined two workflows:

1) is called when item is created to define id and status.

2) is called when item is updated and status is re-calculated if version is major. (It is called in every item change, not only when user wants to publish a major version, because this option doesn't appear in SPD)

I noticed that sharepoint workflow must do a check-out to be able to update metadata, and because of this the version number is incremented. When version is minor, I don't care, but when version is major I have a problem, because just after publishing the version 1.0, the workflow changes metadata and the version to 1.1. and 1.1 means that the document is not approved anymore...


a) Isn't it possible to do the workflow to check-in and override the last/current version to not generate a new version??

b) Or is it possible to stop versi

Object per workflow instance via Extension


I have been trying unsuccessfully to create an extension that will allow me to supply a new instance of a object to each workflow instance.  Specifically, I am attempting to supply a variant of the UnitOfWork class used to managed long running NHibernate ISsessions.  I keep hearing that you can add a service behavior extension on a per-workflow instance basis, but none of the examples I’ve seen show you how.  When I attempt to retrieve the extension in my Activity, I always get the same singleton instance.


public class UnitOfWork : IUnitOfWork


        public Dictionary<string, ISessionFactory&

Workflow instance id from wsHttpContextBinding vs database InstanceTable.Id


I'm working with SqlWorkflowInstanceStore and i'm using wshttpcontextbinding to get workflow instance id for corellation of workflow requests:

IContextManager oContextManager =


string oInstanceId = oContextManager.GetContext()["instanceId"];

but oInstanceId does not map to value of column "Id in System.Activities.DurableInstancing.InstanceTable. Can anyone tell me how to get row of InstanceTable using "instanceId" form IContextManager?


Why did my workflow execute twice the same instance?



I'd like to understand why is happening this. I'm designing a workflow in SPD, and the same workflow run twice!

Look that "Workflow Completed" is presented twice in the Workflow History.

What is happening? I made some wrong configuration?

I'm trying to update some fields in a list after item update (the workflow A is started after item update), so to avoid loops I created an auxiliary list:

On item update in List A it is started the workflow A that creates an item for each operation in the auxiliary list that starts an workflow B on item creation to update the item in list A...

When the Workflow B tries to update the item, the workflow A is started again, but I added a condition: if there is an item in auxiliary list so this workflow had already executed then the item in auxiliaty list is deleted and worflow stopped. But it didn't stop and it run again as you can see in history:


04/10/2010 08:59 Comment

XMLdocument check if path exists (selectnodes throws "Object reference not set to an instance of an


Normally the code below works, EXCEPT if the xpath doesnt exist, then I get the error "Object reference not set to an instance of an object." on the 2nd line

Dim sessionXML As XmlDocument = Session("XML")
If sessionXML.SelectNodes("//root/data/compare/locations/location") IsNot Nothing Then

How can I check if the xpath exists (without a try catch preferably)?

Default Content Approval Workflow not firing after Check-In from Office 2007


I have created an Approval Workflow for a Document Library and assigned it as the Default Content Approval Workflow (in the UI: Start this workflow to approve publishing a major version of an item).

If, through the SharePoint web interface, I "Check-In" and select a Major Version (e.g. 1.0) or I "Publish a Major Version", this workflow is initiated as one would expect.

However, if through Microsoft Office 2007 (e.g. Word) I Check-In the document as a Major Version (e.g. 1.0) it does NOT initiate the workflow. It DOES set the Document Status to Pending but does NOT initiate the Approval workflow. It then becomes necessary to "Cancel [the] Approval" in the GUI and re-Publish it in order for the workflow to be initiated. This is crazy! Microsoft have achieved fantastic results with their Office integration, why hasn't the initiation of the Default Content Approval Workflow been included?

Can anybody replicate this? What is the correct channel for reporting this to Microsoft? Has anybody else discovered this and found a solution?

I can't believe SharePoint has been used as a Document Management System and nobody else has discovered this flaw?

Get the current workflow instance ID in a WF4 workflow service


Is it possible to somehow query the current workflow instance ID (or another unique identifier) within code executed as part of a workflow service?


public sealed class SomeCodeActivity : CodeActivity
  public InOutArgument<List<string>> Messages { get; set; }

  protected override void Execute(CodeActivityContext context)
    var logger = new SimulatedLogger();

public class SimulatedLogger
  public void CreateLog(IList<string> messages)
    //This line throws an exception

Copy List Item in SPD 2010 Workflow Fails if Check Out/Check In Required


I've seen this issue on 3 different Sharepoint 2010 implementations, including upgrades and fresh installations...

The workflow, which works fine in WSS 3.0/MOSS, operates on change of a document.  Workflow reviews a specific column and based on contents of that column, it checks out the document, copies the current item from the current library to another library in the same site and then deletes the item in the current library.

In SharePoint 2010, the following occurs.  Again, this occurs in the upgraded workflow as well as in a brand new workflow created with SPD 2010 on a site that blank / not upgraded.

  • Workflow starts on an item that is verified to not already be checked out.
  • Document is checked out
  • Document IS copied to the other library
  • Workflow fails and is canceled with the following errors:
    The workflow could not copy the item. Make sure the source and destination lists have the same columns and column settings.  (They do.)
    The workflow operation failed because the action requires the document to be checked out. (The item is checked out by workflow - as is evidenced by the fact that the item is still checked out after workflow fails.)
  • RESULT:  the copy operation does work, workflow thinks it doesn't and fails on that step, item is not deleted

I've tes

Workflow - check-out itself


I have problem with my workflow. When I create, it always is check-out with green "check" symbol. Why and what to do.

I have WSS3.0

Dynamically get the current instance of the workflow within a re-hosted WPF application



the scenario is: I create a re-hosted WPF application for the workflow designer, and within this designer I can edit the workflow(sequence, flowchart) with pre-defined and custom activities. The question is, how can I programmatically get an instance of the current workflow. Thereafter I can do some manipulations on this instance.



Sharepoint Workflow - Object Reference Not Set to an instance of an object



I create a Custom Sharepoint workflow using VS 2008. Let me go step by step:

1. I have an infopath form which is a requisition form.  I saved all my infppath source class and other custon class files in a Class library.

2. I built this class library and assigned a string key to it.

3. created a custom sequential workflow and added my class library dll to this workflow.

4. In my workflow I have a function where I am using :

                    using (SPSite currentSite = new SPSite(siteURL))
                        using (SPWeb currentWeb = currentSite.OpenWeb())

Single instance of workflow for a parameter



I'm a newby to WF fnd have a question which I haven't found an answer for:

I've got a WCF workflow service which is invoked by receive activity with a parameter (saleId). My workflow is a long running workflow and I want only a single instance of a workflow to be running for the saleId.

I tried to implement it with correlation mechanisms, however I receive an exception, when starting the secong workflow with the same parameter The execution of an InstancePersistenceCommand was interrupted by a key collision. The instance key with value '{Unique ID}' could not be associated to the instance because it is already associated to a different instance.

And after this exception the execution of the first workflow stops together with the second one.

Extension instance management for workflow service


I have written some custom activities for business validation (http://www.neovolve.com/post/2010/10/13/Custom-Workflow-activity-for-business-failure-evaluatione28093Wrap-up.aspx with project source at http://neovolve.codeplex.com/SourceControl/changeset/view/68064#1422354). They have worked fine until I use them in a workflow service.

The evaluator activity pushes a business failure into a custom extension. The custom extension will then detect whether the evaluator is contained in a scope activity. If there is a scope activity, it will store the failure in the extension for the scope to collect later. If there isn't a scope, it will throw an exception straight away. The scope will look for failures in the extension written by its child activities when it completes and will throw an exception for the set of failures.

This has worked fine so far for workflows executed via WorkflowInvoker and WorkflowApplication. There are unit tests for these activities to ensure that the above behavior is working as expected.

I have just used these activities in a workflow service and found that the extension behavior is very different. The function p

How to check whether the current workflow is valid? Is WorkflowDesigner.IsInErrorState() working?


How to check whether the current workflow hosted in a workflowdesigner is valid?

I tried calling WorkflowDesigner.IsInErrorState() everytime WorkflowDesigner. ModelChanged event fires.. but it always return false (ie no error) even though I see the red error sign in the designer!

any idea?

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend