Manage required fields dynamically


In a big process, we are a lot of fields required, however when a user want to go back to another step with a radio button :

He need to complete all required fields, is not user friendly for them.

In our case, because of the number of fields, is not possible to set condition on all fields.

We want in code behind, be able to manage FORM_FIELD_REQUIRED dynamically, is it possible ?

This part will be launched from an “SelectedIndexChanged” event on “Decision” field.

Thanks for your help or any advices

If what you need is to skip the current action and allow user to complete the action and move to another action, there could be different ways to submit the form without the standard WFG field validation.

Option 1: You can add a button control and onclick event. Within the on click event just call submitToWorkflow. Since this is an added button it does not tie to validationGroup “WFGENPage”, user will be able to submit the action and not required to fill in all required fields, just like the Save As draft button.

Option2: override the standard submitButton and you can try to disable the WFGENPage validation by not setting the ValidationGroup = “WFGENPage” if your selection is “Go back”. I haven’t tested this approach but in theory it should work.

    protected override void OnPreLoad(EventArgs e)
    // Turn off before calling base.OnPreLoad(e)
    HandleSubmitButton = false;
    // Add your custom events to the submit button
    submitButton.Click += new EventHandler(MySubmitButton_Click);
    // Add the validation group constant (Done by WorkflowGen when HandleSubmitButton is true)
    // It is required in order to have the correct WorkflowGen Behaviour with the required fields.
        submitButton.ValidationGroup = "WFGENPage";