Configurator - Get Read Only Expression to fire after Dynamic List refresh

The comboboxes on my Epicor Web Configurator are all populated with Dynamic Lists querying the Configurator Control Data. In the combobox’s On Field Changed expression, I call Refresh.DynamicList on controls having the first box in their criteria.

I’m trying to add a Read Only Expression that will set the combobox’s value and lock it if there is only one value in its list. The expression works, but it runs before the list actually refreshes, however. If I wait for the list to refresh and set focus on any control, the expression fires again and works properly.

How can I get the expression to fire as desired? I wouldn’t be surprised if I’m going about this all wrong and would be happy to be corrected.

//On Field Changed Expression for box1
Refresh.DynamicList("box2");

//Read Only Expression for box2
var items = Inputs.box2["Items"];

if (items.length == 1)
{
Inputs.box2.Value = items[0]["DataValue"];
return true;
}
else
return false;

Does refreshing a control cause any of that controls events (like its OnChange) to fire? If so, you could do the check for the list length in tnat event.

The code below is what I have in my read only fields. In my experience read only goes after everything else. If there are no valid inputs the field will remain read only, if there is only one applicable value for the combo box it will populate it and set the field to read only, if there are multiple applicable values it will remain open for the user to select.

 //default to enabled
    bool FieldDisabled = false;

if (Inputs.(InputName).Control.Rows.Count == 0)       
{
	//no options in combo
	FieldDisabled = true;
}
else if (Inputs.(InputName).Control.Rows.Count == 1) 
{
	//only one option available... set this as default
	FieldDisabled = true;
	if (Inputs.(InputName).Value != Inputs.(InputName).Control.Rows[0].Cells[0].Value.ToString())
	{
		Inputs.(InputName).Value = Inputs.(InputName).Control.Rows[0].Cells[0].Value.ToString();

	}
}

return FieldDisabled;

If this works for you then I feel I need to come clean; I was either given this code or some version of it by @timshuwy.

The On Change and Validating events fire only after the selection is made in the associated combobox. As far as trying to set Read Only alongside the Refresh, it seems the Refresh in a Web Configurator is asynchronous and the rest of the expression continues before the lists are refreshed. If you click quickly enough, you can actually change a value of a different combobox before its list refreshes.

That code is very similar to what I have, but I have to use Typescript for a Web Configurator. The issue is the Read Only expression for box2 fires after the On Changed event of box1 (as expected), but before box2’s list is actually refreshed. In a Product Configurator, Refresh.DynamicList seems to be synchronous and locks the form, but in a Web Configurator, it is asynchronous and you can still use the form fully while the list is updating.

Sorry Ross, I’m not crazy familiar with the web enabled configurators.

Have you thought of making the selection a UDMethod, and calling it after the refresh?

Not a problem, I appreciate the suggestions. Web Configurator doesn’t seem to be a common thread, so it’s been a bit of an uphill battle getting started with development.

Having the Refresh in a client-side UDMethod has the same outcome. Server-side UDMethods don’t seem to have Refresh capability.