1

I need to programmatically get AssociationData of the running workflow from console application. Now I can only get AssociationData of its parent (workflow association at the list).

using (SPSite site = new SPSite("http://sp:2200"))
    {
        using (SPWeb web = site.OpenWeb())
        {
            string parentAssociationData =
                web.Lists["TestWorkflow"].GetItemById(1).Workflows[0].
                    ParentAssociation.AssociationData;
        }
    }

I need something like this

string neededData = item.Workflows[0].AssociationData;

because when you start workflow manually and change its settings right before start: workflow.AssociationData != workflow.ParentAssociation.AssociationData

For example I can get that data in the custom workflow through the

SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties();
workflowProperties.AssociationData
ronalchn
  • 12,225
  • 10
  • 51
  • 61
user1665961
  • 46
  • 1
  • 4

1 Answers1

1

I think you misunderstand AssociationData. The association data is only entered once upon associating the workflow with your list. You said that you are changing the settings right before start - in that case you are talking about InitiationData!
SPWorkflowActivationProperties.InitiationData will help you:

--> Gets the initiation data passed to the workflow instance.

Dennis G
  • 21,405
  • 19
  • 96
  • 133
  • Thank you for the answer. Yes you are right. How can I get SPWorkflowActivationProperties object using SPWorkflow object? – user1665961 Sep 13 '12 at 08:49
  • I found similar post. [link](http://www.sharepointdev.net/sharepoint--workflow/how-do-i-get-initiationdata-from-a-workflow-that-is-running-44386.shtml) "otherwise, from a non workflow aspx page, well, you cannot...(unless your workflow stores its initiationData into a custom list or a custom column which cannot be done by OOB workflows)" – user1665961 Sep 13 '12 at 08:57