Can't make a custom Control Settings work

Hi all,

I just can’t make my custom ControlSettings work. I’m in 10.2.700.15. When I use SettingStyle (comment line), every thing is ok. Can somebody point me where the problem is…

private void AddRROnQuoteDtl()
	{
		var quoteDtlView = oTrans.Factory("QuoteDtl");
		var myCustomSetting = new ControlSettings() { BackColor = Color.Orange, ForeColor = Color.Black };	
		
		mandatoryOrderDtlFieldList
			.ForEach(field => 
			{				
				var rrEmptyField = new RowRule( "QuoteDtl." + field, RuleCondition.Equals, "");
	            rrEmptyField.AddAction(RuleAction.AddControlSettings(oTrans, "QuoteDtl." + field, myCustomSetting));
			//	rrEmptyField.AddAction(RuleAction.AddControlSettings(oTrans, "QuoteDtl." + field, SettingStyle.Warning));
	            quoteDtlView.AddRowRule(rrEmptyField);
			});
	}

my working version is a bit different, but this should work adapted for you

var action = RuleAction.AddRowSettings( this.oTrans, "QuoteDtl", false, myCustomSetting);
var actions = new RuleAction[]{ action };
var rrEmptyField = new RowRule( "QuoteDtl." + field, RuleCondition.Equals, "", actions);
quoteDtlView.AddRowRule( rrEmptyField );

Thanks Joseph for your reply,

No, your proposition doesn’t work for my context. But it works (i tried it). In your proposition, your using a RowSettings wich will apply the action on all fields of the row.

My step are:

1- Adding RowRules on Load (I’ve also tried to add them in the Initialize)
2- After the form is open, I search for a Quote with no lines
3- After clicking on the GetNew button, the row rules are working with the SettingStyle action but not with the ControlSettings.

I get the same behavior in another screen. I just can’t figure why the ControlSettings doen’t work. I’ve also tried to use the Wizard to create a RowRule and inside of the method, I have replace the SettingStyle by the ControlSettings with not positive result.

Any ideas?

Interesting, I did some testing and the following works for me for individual blank string fields. My guess would be something with the dataview returned from oTran.Factory maybe? The only other difference I see is passing the action[] in the row rule constructor vs. the add action method.

var view = (EpiDataView)this.oTrans.EpiDataViews["QuoteDtl"];
ControlSettings myControl = new ControlSettings();
myControl.BackColor = System.Drawing.Color.Navy;

fieldList.ForEach( field => 
{
	string binding = view.ViewName + "." + field;		
	view.AddRowRule( 
		new RowRule(binding, RuleCondition.Equals, "", 
			new RuleAction[]
			{ 
				RuleAction.AddControlSettings(this.oTrans, binding, myControl ) 
			})
	);
						
});

Thanks for your help @Joseph_Martin ,

Still not working. I’ve copied and pasted your code with no positive result. Although, the SettingStyle does work.

Don’t pull your hair out. It takes some special magic to use non-built in styles.

Search this site a little more. Particularly for a post by @josecgomez. If I find it I’ll post a link

Edit

Here you go

Thanks @ckrusen for your support,

It’s the first thing I did when I notice my code was not working. I did plenty of code with ControlSettings, particularly with the Epicor SDK. I’ll keep investigating …

Got it. After decompiling the EpiClientLib.dll and making some tests, I finally made it work. First time I’ve encountered such problem. It always worked nicely before. Anyway, I got what I want.

EDIT. When the StyleSetName was left empty, it did not have the behavior expected.

1 Like