How to trigger 'IsRequired' on configurator via button

Does anyone know how to trigger ‘IsRequired’ on the configurator via a button. I set the required attribute on an input and it triggers on page leave but i would like it to trigger when users click a button. I don’t know the call.

Thanks,

I know this can be done by looping through the controls and looking for the property IsRequired = true and then checking the presence of a value. I believe there is a way to do this differently but I will have to dig that up.

@danbedwards

I tried to access a IsRequired Property or Required property on the controls but it is not finding that property.

I am trying this:

foreach(Control ctrl in Inputs.cbDebug.Control.Parent.Controls) {

if (ctrl.IsRequired == true) {

}

}

Any suggestions?

Use something like this

bool IsRequired = ((InputControlValueBound<Ice.Lib.Framework.EpiTextBox,String>)Inputs[ctrl.Name.ToString()].Value).Required;

@danbedwards
Just figured it out at the same time. Thanks!

@danbedwards

A follow up, I am also trying to get the read only status of the control I have this:

((InputControlValueBound<Ice.Lib.Framework.EpiTextBox,String>)Inputs[ctrl.Name.ToString()].Value).ReadlOnly

But the system does not like it. It says there is no such property. Any ideas how I reference if a control is in a read only state?

This will work for finding if read-only or not

bool RO = ((Ice.Lib.Framework.EpiTextBox)ctrl).ReadOnly;

@danbedwards

I am attempting to try and loop through all the controls on the form and set required to false. I have this but it doesn’t work. Any suggestions?

foreach(Control ctrl in Inputs.cbDebug.Control.Parent.Controls) {
			if (ctrl is Ice.Lib.Framework.EpiTextBox) {
				var tb = (InputControlValueBound<Ice.Lib.Framework.EpiTextBox,String>)Inputs[ctrl.Name.ToString()].Value;
				if (tb.Required == true) {					
					((Ice.Lib.Framework.EpiTextBox)tb.Control).EpiRequired = false;
				}
			}
			if (ctrl is Ice.Lib.Framework.EpiUltraCombo) {
				var tb = (InputControlValueBound<Ice.Lib.Framework.EpiUltraCombo,String>)Inputs[ctrl.Name.ToString()].Value;
				if (tb.Required == true) {
					((Ice.Lib.Framework.EpiUltraCombo)tb.Control).EpiRequired = false;
					MessageBox.Show(ctrl.Name.ToString());
				}

You need to change this

((Ice.Lib.Framework.EpiUltraCombo)tb.Control).EpiRequired = false;

To

tb.Required = false;

For both the text and combo controls.

@danbedwards

I had tried that originally and it wasn’t working. Everything I tried wasn’t working until i found out the issue. If i set the required attribute on an input in the designer, no matter what i did in an onchange / onclick event for an input, it would not change the required to false.

I found if i instead left the required as false in the designer and then in the onpageload of the page set the inputs to required that i wanted to be required, i could then unset or set again the required value via onchange / onclick events.

Not sure why but that is what i found out.

What is the exact version of Epicor are you using? This worked for me in 10.1.400 and 10.1.500.

@danbedwards

10.1.500

Attached is a video of this code running on 10.1.500.8 and I also tested on 10.1.500.22. Is this how you are testing or are you trying to read and display the attribute again? The code is also displayed during this video.
Configurator_Required.mp4 (1.4 MB)

@danbedwards

Interesting. i did that exact same thing and it doesn’t work for me. Required is never removed. I am on 10.1.500.12.

That is interesting. I have a .12 build running that I will test this on.

I just ran a test in 500.12 and it worked as well. I attached the test product configurator if you want to try and see if that makes a difference.

Configurator_Required.xml (25.6 KB)

@danbedwards
I took your configurator and tested it. You are right it, works, however, after some digging i found an issue. I don’t know why and hope you or someone can explain. If you call a UDMethod, with Method Type of Server right after setting the required to false, it resets it back to true. I will attach your configurator with a UDMethod call and you will see it will not remove ‘required’.
Configurator_Required.xml (26.6 KB)

You should always use a client UD method or client side event for manipulating the screen. I am kind of surprised the server side method even worked.

@danbedwards
I don’t actually manipulate the screen using a server side UDMethod. I do call out to the database to get information that i then send to inputs on the screen.

Even if the server side UD method is completely empty, just having it’s method type as server causes the required attribute to be reset.

I could be wrong @jdewitt6029, but I’m pretty sure you can call a server UD from a client UD. Might want to see if that preserves the attribute.

Mark W.