Get Input Arguments to .xaml as Dictionary from within .xaml

Hi all,

I am having trouble producing a solution to the following problem.

I have a .xaml workflow that I want to use as a template for later projects. The workflow needs to be able to take in different input arguments depending on future developers’ needs. Because this is a template, the number, type, and names of the inputs are all unknown ahead of time. In order to simplify the template for later use, I would like to take the list of input arguments and read them into a Dictionary(of String, Object).

Here is an example of what I mean. I have the following In arguments to the workflow.

image

I would like to read these inputs into the following Dictionary format.

{
“TestArg1” : ###value passed from external function###
“TestArg2” : ###value passed from external function###
}

Note that if the argument names were instead “foo” and “bar”, I would want the dictionary to read {“foo” : #val#, “bar” : #val#}, if there were more arguments it would need to include more entries, etc.

Does anyone know of a way to accomplish this? I am not set on a specific format by the way, but I would like to end up with some object within the workflow that contains all the arguments and their values.

Thanks in advance for any help!

1 Like

you can use the below XAML File to read the arguments, later you can add code to add dictionary

readarguments.xaml (13.7 KB)

1 Like

Thanks so much for your reply. I downloaded and have been working with the workflow you posted. I was unable to get it to work. I keep getting an error “The namespace ‘x’ was not defined” under the assign activity ArgumentsNodes = diagramTree.DocumentElement.SelectNodes(“x:Members”, namespaceManager). I thought it might be the NamespaceManager, so I tried initializing it after diagramTree was already populated, but this had no effect. Any thoughts on how to resolve this?

As an aside, while your solution would answer my question, I am curious if it would work once packaged and published to Orchestrator. The NuGet packages Orchestrator works off of are written in assembly, so there is no xml or xaml document to break apart. Do you know if this solution works when published to Orchestrator? If not, any ideas on how to get this solution working in Orchestrator? We are working in an environment where this will need to work well with Orchestrator to be viable.

Thanks,
Michael

i tested in my machine its working…

i am not sure about the package

Can you show me exactly how you are running the workflow? Are you invoking it from another workflow? What arguments are you passing to it?

You have to add namespace using Invoke method and add following parameters while adding namespace.

image

http://schemas.microsoft.com/winfx/2006/xaml
“x”