Should I Be Concerned About my Row Rule

So, I have a Row Rule and I added code to change the background color to Orange instead of using one of the Setting Styles. Everything works fine except when I go back into the Customization screen. Every time I open it I get the following error.

Application Error

Exception caught in: mscorlib

Error Detail 
============
Message: Length cannot be less than zero.
Parameter name: length
Program: CommonLanguageRuntimeLibrary
Method: Substring

Client Stack Trace 
==================
   at System.String.Substring(Int32 startIndex, Int32 length)
   at Ice.Lib.Customization.CustomCodeParseManager.ParseRuleActionCode(CustomizationLanguage custLanguage, String raCodeLine, RuleActionInfo raInfo)

Should I be concerned that this might cause an issue down the road? Everything compiles fine and the rows are highlighting orange. I just don’t want to mess up the system in some unknown way. Here is the code that (I think) is causing the error.

private void CreateRowRuleCurrentWorkCheckBox03Equals_true()
	{
		// Description: CWFAI
		// **** begin autogenerated code ****
		ControlSettings controlSettings = new ControlSettings();
		controlSettings.IsReadOnly = false;
		controlSettings.BackColor = System.Drawing.Color.Orange;
		controlSettings.ForeColor = System.Drawing.Color.Black;
		RuleAction errorCurrentWork_RowAction = RuleAction.AddRowSettings(this.oTrans, "CurrentWork", true, controlSettings);
		RuleAction[] ruleActions = new RuleAction[] {
				errorCurrentWork_RowAction};
		// Create RowRule and add to the EpiDataView.
		RowRule rrCreateRowRuleCurrentWorkCheckBox03Equals_true = new RowRule("CurrentWork.CheckBox03", RuleCondition.Equals, true, ruleActions);
		((EpiDataView)(this.oTrans.EpiDataViews["CurrentWork"])).AddRowRule(rrCreateRowRuleCurrentWorkCheckBox03Equals_true);
		// **** end autogenerated code ****
	}

It’s when it’s trying to add it to the tree in customization mode. Remove the comments from that method and see what happens.

1 Like

Still not working. I am going to try a Custom Action instead. I’ll report back.

image

This here is where I have seen things go sideways when you start messing with row rules manually. If going that route I don’t use the wizard at all to stop the parser from freaking out.
image

Something concise on these lines

private void PromiseDatePast_Rule()
    {
        var action = RuleAction.AddControlSettings(this.oTrans, "V_WCI_Dispatch_1View.JobHead_PromiseDate_c", SettingStyle.Error);
        var rr = new RowRule("V_WCI_Dispatch_1View.JobHead_PromiseDate_c", new RowRuleConditionDelegate2(PromiseDatePast_Condition), "Check", new RuleAction[] { action });
        edvV_WCI_Dispatch_1View.AddRowRule(rr);
    }
    private bool PromiseDatePast_Condition(Ice.Lib.ExtendedProps.RowRuleDelegateArgs args)
    {
        return (!string.IsNullOrEmpty(args.Arg1.ToString()) && DateTime.Parse(args.Arg1.ToString()) < (DateTime)args.Row["JobHead_DueDate"]);
    } 
2 Likes

@jkane - when I use your code, testing (on the ABC form) yields:

Error: CS0118 - line 64 (168) - 'Ice.Lib.ExtendedProps.ControlSettings' is a 'type' but is used like a 'variable'

where line 64 is

RuleAction highlightAbcCode_RowAction = RuleAction.AddRowSettings(this.oTrans, "AbcCode",true,ControlSettings);

@jgiese.wci Awesome! Thank you.

That needs to be a lower case c

controlSettings

D’ Oh!

After fixing that, it compiles and runs as expected. Or does it always work when launching in developer mode, and only fails when that customization runs in normal mode?

It actually does not fail at all. Everything works and compiles fine. I was getting that error when I would do Tools-Customization.

1 Like