none
Mapped Variable / External Variable not being persisted when declared as a workflow variable RRS feed

  • Question

  • When publishing my workflow definition, I specify three mapped / external variables, i.e: 

    client.PublishWorkflow(workflowName, @"..\..\MyWorkflow.xaml",
    	new Collection<ExternalVariable>
    		{
    			new ExternalVariable<string> { Name = "AccountID", Modifiers = System.Activities.VariableModifiers.Mapped },
    			new ExternalVariable<int[]> { Name = "AssignedDomains", Modifiers = System.Activities.VariableModifiers.Mapped },
    			new ExternalVariable<int> { Name = "OfficeID", Modifiers = System.Activities.VariableModifiers.Mapped }
    		},
    	new Dictionary<string, string>()
    		{
    			{ "ApprovalReminderPeriodHours", "1" },
    			{ "ResubmissionReminderPeriodHours", "1" }
    		});

    Within the workflow, OfficeID is defined as an input argument, whereas AccountID and AssignedDomains are just variables at the root workflow scope.

    After starting an instance of the workflow, only the OfficeID is accessible via mapped variables and only OfficeID is persisted to the WFInstanceManagementDB.dbo.MappedVariables database table. The other two are nowhere to be found.

    Has anyone else experienced this?

    Thursday, May 30, 2013 1:33 AM

Answers

  • After a deeper dive into this issue, I was able to find the solution.

    The snap-in window for workflow variables (and arguments, imports) shows columns for Name, Variable type, Scope and Default. However, the properties window for each workflow variable shows one more field - Modifiers. This is where I was able to specify a value of Mapped for the AccountID workflow variable. I was then able to publish and start the workflow without the need to explicitly include AccountID in the collection of external variables as per my original code example. The AccountID variable is now persisted to the database (WFInstanceManagementDB.dbo.MappedVariables) and is available via the REST API.

    • Marked as answer by darianf Tuesday, June 4, 2013 12:44 AM
    Tuesday, June 4, 2013 12:44 AM

All replies

  • After a deeper dive into this issue, I was able to find the solution.

    The snap-in window for workflow variables (and arguments, imports) shows columns for Name, Variable type, Scope and Default. However, the properties window for each workflow variable shows one more field - Modifiers. This is where I was able to specify a value of Mapped for the AccountID workflow variable. I was then able to publish and start the workflow without the need to explicitly include AccountID in the collection of external variables as per my original code example. The AccountID variable is now persisted to the database (WFInstanceManagementDB.dbo.MappedVariables) and is available via the REST API.

    • Marked as answer by darianf Tuesday, June 4, 2013 12:44 AM
    Tuesday, June 4, 2013 12:44 AM
  • Hi darianf, I have trouble setting external variables from workflow. con you please (if possible) post here your "MyWorkflow.xaml" code?

    Because as you suggest in my wf I set Mapped as value of Modifiers of a variable but I cannot see the variable and its value in MappedVariable DB table.

    Thanks,

    Friday, August 8, 2014 5:05 PM