Handling Multiple Criteria for a RowRule

Hello.
I am trying to create a RowRule that has two criteria. We want to highlight the Order Qty. if it is zero, but this should really only occur when a Part Number has been entered.

I used the Wizard to create both RowRules so that I would have the correct syntax for both, then copied and pasted the second rule as follows:

private void CreateRowRuleOrderDtlSellingQuantityEquals_0()
{
	// Description: Highlight Order Qty if Zero
	// **** begin autogenerated code ****
	RuleAction highlightOrderDtl_SellingQuantity = RuleAction.AddControlSettings(this.oTrans, "OrderDtl.SellingQuantity", SettingStyle.Warning);
	RuleAction[] ruleActions = new RuleAction[] {
			highlightOrderDtl_SellingQuantity};
	// Create RowRule and add to the EpiDataView.
	RowRule rrCreateRowRuleOrderDtlSellingQuantityEquals_0 = new RowRule("OrderDtl.SellingQuantity", RuleCondition.Equals, 0, ruleActions);
	((EpiDataView)(this.oTrans.EpiDataViews["OrderDtl"])).AddRowRule(rrCreateRowRuleOrderDtlSellingQuantityEquals_0);
	RowRule rrCreateRowRuleOrderDtlPartNotEmpty = new RowRule("OrderDtl.PartNum", RuleCondition.NotEqual, null, ruleActions);
	((EpiDataView)(this.oTrans.EpiDataViews["OrderDtl"])).AddRowRule(rrCreateRowRuleOrderDtlPartNotEmpty);
	// **** end autogenerated code ****
}

When I create a new line, the Order Qty. immediately becomes yellow even though no part has been entered.

What is the correct way to handle multiple critieria for Row Rules?

Maybe put inside case or if statement?
If SellingQuantity Not Null Then RowRule#1 , Else RowRule#2

We usually handle this by low-teching it and making multiple rules that fire in the correct order.

Rule 1 - If order qty = 0 then highlight field
Rule 2 - If part number is blank then set field back to not highlighted

You can do a Custom Condition.

Thanks Haso.

I might need a little help with the syntax on the custom rule method since the Order Qty. field is still highlighted when a new line is created. Here’s the code I came up with:

private void CreateRowRuleOrderDtlSellingQuantityCustomCondition_true()
{
	// Description: Highlight Order Qty When Zero And Part Not Null
	// **** begin autogenerated code ****
	RuleAction warningOrderDtl_SellingQuantity = RuleAction.AddControlSettings(this.oTrans, "OrderDtl.SellingQuantity", SettingStyle.Warning);
	RuleAction[] ruleActions = new RuleAction[] {
			warningOrderDtl_SellingQuantity};
	// Create RowRule and add to the EpiDataView.
	RowRule rrCreateRowRuleOrderDtlSellingQuantityCustomCondition_true = new RowRule("OrderDtl.SellingQuantity", new RowRuleConditionDelegate2(this.OrderDtlSellingQuantitytrue_CustomRuleCondition), true, ruleActions);
	((EpiDataView)(this.oTrans.EpiDataViews["OrderDtl"])).AddRowRule(rrCreateRowRuleOrderDtlSellingQuantityCustomCondition_true);
	// **** end autogenerated code ****
}

private bool OrderDtlSellingQuantitytrue_CustomRuleCondition(Ice.Lib.ExtendedProps.RowRuleDelegateArgs args)
{
	bool result = false;
	// ** RowRuleDelegateArgs Properties: args.Arg1, args.Arg2, args.Context, args.Row
	// ** put Row Rule condition evaluation logic here
	EpiDataView OrderDtlView = ((EpiDataView)(this.oTrans.EpiDataViews["OrderDtl"]));
	DataRow OrderDtlRow = OrderDtlView.CurrentDataRow;
	if(OrderDtlRow != null)
	{
		string partNum = OrderDtlRow["PartNum"].ToString();
		int ordQty = Convert.ToInt32(OrderDtlRow["SellingQuantity"]);
		if(partNum == "" && ordQty == 0) result = true;
	}
	return result;
}

I admit that the syntax is simple-minded, but it’s the best I could come up with on short order.

Any idea what I might have overlooked? BTW, I did re-review your YouTube video but didn’t see any clear-cut examples that appeared to be close to what I’m attempting here.

Here is an example that I have on Order. In my example I want to look at all Releases and see if there are Unfirmed ones so I can show a Shape on the Summary Tab (OrderHed).

You may need to check for if (OrderDtlView.Row != -1) if the row still hasn’t been saved to simply return false. Sometimes you also can run it if RowMod != A or LineNum != 0

private bool OrderRelFirmReleasefalse_CustomRuleCondition(Ice.Lib.ExtendedProps.RowRuleDelegateArgs args)
{
	EpiDataView edvOrderRel = this.oTrans.Factory("OrderRel");

	if (edvOrderRel.Row != -1 && edvOrderRel.dataView.Count > 0) {
		return !Convert.ToBoolean(edvOrderRel.dataView.Table.Select("FirmRelease = 0 AND OpenRelease = 1").Length > 0);
	}

	return true;
}

Basically sometimes I run the RowRule wide open on something like LineNum or RelNum and then just evaluate.

RowRule rrCreateRowRuleOrderRelOrderRelNumNotEqual_A = new RowRule("OrderRel.OrderRelNum", RuleCondition.NotEqual, "", new RowRuleActionDelegate2(this.OrderRelOrderRelNumNotEqualA_CustomRuleAction), contextObject);

Thanks Haso. I’m pretty sure that was what I needed to learn. I honestly didn’t know you could simply pass a SQL query in that way. Here’s the final code for posterity:

	private bool OrderDtlSellingQuantitytrue_CustomRuleCondition(Ice.Lib.ExtendedProps.RowRuleDelegateArgs args)
	{
		bool result = false;
		EpiDataView OrderDtlView = ((EpiDataView)(this.oTrans.EpiDataViews["OrderDtl"]));
		if(OrderDtlView.Row != -1 && OrderDtlView.dataView.Count > 0)
		{
			result = Convert.ToBoolean(OrderDtlView.dataView.Table.Select("PartNum <> '' AND SellingQuantity = 0").Length > 0);
		}
		return result;
	}

Thanks Again,
Tony Gardner