Product Configurator - Object Reference Error

The following is an issue you can encounter when using the Product Configurator. This issue is present in 10.2.300 – 10.2.400 and I assume even earlier versions have the same “feature”. While this example is specific to controls and events - there are several other scenarios that cause the same issue. Here goes …

image

In this example the controls have the following function / code.
1 – A simple text box with no actions or expressions defined

2 – A button with the following On Clicked Expression

MessageBox.Show("Character Box value is: " + (Inputs.CharacterBox.Value ?? "null"));

3 – A button with the following On Clicked Expression

Inputs.CharacterBox.Value = "";

4 – A Combo Box that uses a dynamic list with the Param bound to Text Box ( 1 )
image
5 – A button that refreshes the dynamic list in the Combo Box ( 4 )

The Problem

  • Launch the configurator using Test Inputs

  • Click Display Value button ( 2 ) and you will see this message image

  • Click the Refresh Dynamic List ( 5 ) and it will not fail but does not fill the Combo Box, which is expected

  • Enter a Value in the Text Box ( 1 ) and click the Display Value button ( 2 ) again.
    You will see your value appear like this image

  • Click the Refresh Dynamic List ( 5 ) and the Combo Box will populate

  • Click the Clear Character Box button ( 3 ) which will clear the Text Box ( 1 ) and then click the Display Value button again to see this image

  • Click the Refresh Dynamic List ( 5 ) and you will get the following error
    image

The Solution

Change the code for the Clear Character Box ( 3 ) to the following:

3 – A button with the following On Clicked Expression

/* Set character box value to a blank string */

Inputs.CharacterBox.Value = "";

Inputs.CharacterBox.Control.Nullable = false; // The solution 

I have attached the example configurator in a zip file with the solution commented out so you can see the error.
Example.zip (7.9 KB)

Is an “empty string” considered to be equal to NULL?

I always thought "" (a null string) != NULL

And your first Message box shows,
Character Box value is: (with nothing after the colon)

The first message is on form load when Epicor handles the Text Box and it does return empty. Any time after that if you clear the control it returns null. This behavior comes from the Infragistics control, which is doing exactly as documented, and returning null when empty “”.

Interesting.
So if the textbox is originally nullable, why doesn’t the first press of of Button 2 (after the initial form loads), show “Null” ?

That is a good question. Epicor handles this until the event to change the value takes place and then the behavior changes to allow the null. Sure seems like a bug.

Hi Dan,
I noticed that at item 4 the combo box is referencing a UD Method to populate the field, is it a Client Side or Server Side method? The on Load is a Server Side function, the properties may not be available yet on the Input in the On Load context.
–Aaron

That would be a client UD method which basically just reads the Text Box. When the configurator loads we have no issues at all. It is after the load event when you start to clear the actual inputs where the problems occur. This is the code for the sample UD method. There are many scenarios that can trigger this and this is just one of those - all unrelated to the load or even on loaded event.

/* Ensure parameter is not null if passed in as null */
CharacterBoxValue = CharacterBoxValue ?? "";

string listValues = CharacterBoxValue + "`" + CharacterBoxValue;

return listValues;