Use the constructor that takes a RowRuleConditionDelegate2 instead

Hoping this is the last little bit of code that needs debugging for 10.1.400 upgrade to 10.2.300.
This is our last form customization that needs to verify.

Warning: CS0618 - line 730 (2265) - ‘Ice.Lib.ExtendedProps.RowRule.RowRule(object, Ice.Lib.ExtendedProps.RowRuleConditionDelegate, object, Ice.Lib.ExtendedProps.RuleAction[])’ is obsolete: ‘Use the constructor that takes a RowRuleConditionDelegate2 instead’

private static void CreateRowRulePartShortChar01CustomCondition_Constant_NullValue()
{
	//disable piece qty on line item screen if dimensional and multiple releases
	RuleAction disabledPODetail_Number04 = RuleAction.AddControlSettings(oTrans, "PODetail.Number04", SettingStyle.Disabled);
	RuleAction[] ruleActions = new RuleAction[] {disabledPODetail_Number04};
	RowRule rrPartShortChar01CustomCondition_Constant_NullValue = new RowRule("Part.ShortChar01", PartShortChar01ConstantNullValue_CustomRuleCondition, "None", ruleActions);
	((EpiDataView)oTrans.EpiDataViews["PODetail"]).AddRowRule(rrPartShortChar01CustomCondition_Constant_NullValue);
}

Any hints or help are much appreciated.

-JM

I’d take a look at the declaration of PartShortChar01ConstantNullValue_CustomRuleCondition
If you replace it with RuleCondition.Equals, then it appears to work.

I agree with AndrewM, I am not even sure why you are specifying PartShortChar01ConstantNullValue_CustomRuleCondition, do you want to handle the Validation Logic yourself?

Hello,

Thanks for the hints here. I will take a look when I get moment. Here is the PartShortChar01ConstantNullValue_CustomRuleCondition:

indent 	private static bool PartShortChar01ConstantNullValue_CustomRuleCondition(object Arg1, object Arg2)
{
	bool result = false;

	if ((bool)PODetail.dataView[PODetail.Row]["MultiRel"] == true)
	{
		result = true;
	}

	return result;
}text by 4 spaces

Since there is no error\null checking you could reduce your func to this below. However, I think those fields are nullable, so if I were you, I’d check the value for null.

	private static bool PartShortChar01ConstantNullValue_CustomRuleCondition(object Arg1, object Arg2)
{		
    return (bool)PODetail.dataView[PODetail.Row]["MultiRel"];
}

Thanks guys…

I am going to punt on warning for now.
I tested the functionality in the UI that this routine is tied to and things are working as expected thus far.
So since this is just a warning and this is a DEV environment, I’ll just work with things as they are and address later.

I did find that replacing the declaration with RuleCondition.Equals allows things to compile correctly.

I have not tried so skinny up function yet… I would want to know how to check for the nulls as mentioned when I get around to that part.

Thanks,
JM

There are many ways, this one is pretty straight forward. By using a try/catch block, we trap any errors. Since the default result is false, if an error occurs (like the field is null), you get a false.

bool result = false;
try
{
   result = (bool)PODetail.dataView[PODetail.Row]["MultiRel"];
} catch{}
return result;

In your case, it’s probably not an issue, but in many cases you can run into errors, like if no row is selected (or has been deleted without being updated) and some fields wont have a value and would throw a null error when trying to cast them to a desired type.