Form Designer: DropDownList control's selected value not submitted to the server when its EnableViewState property is disabled and the control is in read-only

Issue

When EnableViewState is set to False on a drop-down list and this list becomes read-only during an action, an unexpected behavior occurs.

The selected item in the drop-down list will no longer be selected after the read-only action, although it will be visible in the form_archive and in the next action. This can then have other impacts on your workflow.

The cause is that the data was not properly sent to the server.

Here is a visual representation of this error.

In the following screenshot, we can see that one list has enableviewsstate set to false and the other one does not:


On the second action of this process, the Request section becomes read-only, so both lists will be affected by this configuration:


Now, let’s do a test.

After the first action, the form_archive contains all of the information and both lists are set to Item 1:

During the second action, the Request section is read-only. After submitting the second action, the form_archive does not contain the correct information for the first list:

Then, when launching the following action, the information that was selected is lost:

Workaround

There is a possible workaround for this unexpected behavior by re-enabling the field during the form submit using the following JavaScript code:

$('#submitButton').click(function(){
    $('#[ID_OF_YOUR_FIELD]').prop("disabled",false);
});

In the Form configuration panel, you must have Enable AJAX mode checked on the General tab and Include jQuery API and jQuery UI libraries checked on the Web References tab.

ID_OF_YOUR_FIELD represents the full ID of your drop-down list. For example, if it’s located in the REQUEST section and your drop-down list ID is DDL1, then the full ID will be REQUEST_DLL1, and it will look as follows:

$('#submitButton').click(function(){
    $('#REQUEST_DLL1').prop("disabled",false);
});

Note that this solution will change the property of this field for all actions of your workflow.