Creating a completely Dynamic Form
Quick question; not even 100% it's possible as I'm relatively new to the workflows:
We need to create a fully dynamic form in a workflow. Currently I've got a workflow that reads in an XML file which specifies the required form items, datatypes, validations, etc. I use this to define all the necessary TextBoxFormItem objects in a list, which I then can add to the form during runtime modifications (add range to form.ContainerFormItem.FormItems). I'm setting the argument name of the form items dynamically as well. Because this form is totally dynamic, we can't tie any of these text boxes and other form elements to variables in the output argument section of the form designer as you would normally
When we run the workflow everything looks great and the form displays exactly as intended. Validations all work, etc. but when we move on to the next step of the workflow, we can't access the data the user entered into the form because we cant assign it to any variables. I've tried iterating through the forms GetResults collection of FormItemResults. All of the dynamic argument names are present, but none contain a value. They don't contain values even for elements defined in the form traditionally, so perhaps that's just the behaviour of the workflow.
So... the question is: Is there a way to get the values from the form if we create the form elements dynamically? Is it possible to "bind" a variable to a text box dynamically in the same way as you can assign Output Arguments in the form designer?
Thanks!
-
Could you maybe provide us with a small sample workflow that reproduces this behaviour?
0 -
Have you tried returning the results of your DisplayForm in a Dictionary?
Might be worth a shot to see if it fixes your problem.
0 -
I just tried that suggestion, and it seems to be working. Set the Form Results property of the DisplayForm to a new variable of type Dictionary<String, Object> , and make sure that every form items has set its ArgumentName property. For instance:
new CheckboxFormItem() With { .Text="Check this out", .Checked=True, .ArgumentName="MyCheckBox" }
The keys of the dictionary will be set to the argument names of the formitems.
0 -
Ash or Berend, would it be possible for you to post a workflow example? I'm interested to see how you did so much of this dynamically.
Thanks
0 -
I've tried what was suggested (including the Workflow) and it works well in the Workflow Simulator, but when the workflow is attached to a SL Viewer (v3.15) nothing comes through from the Form Results. I'm yet to try it on a later version of the the viewer but will try that too.
0 -
Just to follow up, our vendor has confirmed it doesn't work in v3.15 with SL 1.10 or 1.10.1 but it works fine from 4.0
0 -
A bit late back to the party, but thanks everyone for the replies and suggestions. We figured out setting the Form Results to a Dictionary was the trick (as suggested by 'Corporate Mapping, TMR' and confirmed by Berend Veldkamp), but forgot to update this thread with the results, so I'm glad someone else picked up the slack. Thanks again for everyones help!
0 -
Hi, many thanks for the above solution, I realize that this thread has been quite for a while, but on the topic of dynamic forms, and runtime mods, I have a problem trying to implement validation
I have got the following
new TextBoxFormItem() With { .DefaultText=itemList.Attributes(tableAttributeCommentName).ToString, .ArgumentName=itemList.Attributes("OBJECTID").ToString, .Label= New LabelFormItem() With {.Text = itemList.Attributes(tableAttributeName).ToString }, .ValidationItems = New ValidationItemCollection(new RegexValidationItem() with {.Expression = "^[+]?\d+$" }) }
And get the error ValidationItemCollection not defined
Any help on dynamically adding validation would be gratefully appreciated0 -
Hi Chris,
The "ValidationItemCollection not defined" error can likely be resolved by either- Changing New ValidationItemCollection to New Geocortex.Forms.Client.Items.Validation.ValidationItemCollection?
- Opening the "Imports" pane (at the bottom of Workflow Designer, next to "Variables" and "Arguments" and adding the namespace Geocortex.Forms.Client.Items.Validation
Hope that helps!
Amanda0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
9 Kommentare