First of all, I want to wish all my Epicor colleagues a very Merry Christmas and a Happy and Prosperous New Year!
.
I am attempting to specify two Rule Actions within one RowRule. In Hasokeric’s famous tutorial, he shows how this can be done, but in his example, all the actions are for AddControlSettings. In mine, I’m attempting to use an AddRowSettings to disable an entire row, then use an AddControlSettings to re-enable the field used to toggle the disabled status.
Specifically, I added an Inactive_c UD field to ShipTo, and want to disable all the fields except itself when it is checked. That way, the user can still uncheck it if they want to re-enable all the fields.
I have had some success when creating two separate RowRules, but am curious to know if this can be done with one. Here is the code with the two separate RowRules:
private void CreateRowRuleShipToInactive_cEquals_True_1()
{
// Version 1.3.0
// Description: DisableShipToWhenInactive
RuleAction disabledShipTo_RowAction = RuleAction.AddRowSettings(this.oTrans, "ShipTo", false, SettingStyle.Disabled);
RuleAction[] ruleActions = new RuleAction[] {disabledShipTo_RowAction};
// Create RowRule and add to the EpiDataView.
RowRule rrCreateRowRuleShipToInactive_cEquals_True_1 = new RowRule("ShipTo.Inactive_c", RuleCondition.Equals, true, ruleActions);
((EpiDataView)(this.oTrans.EpiDataViews["ShipTo"])).AddRowRule(rrCreateRowRuleShipToInactive_cEquals_True_1);
}
private void CreateRowRuleShipToInactive_cEquals_True_2()
{
// Version 1.3.0
// Description: EnableInactiveCheckbox
ControlSettings controlSettings1Default = new ControlSettings();
controlSettings1Default.SetStyleSetName("Default");
RuleAction defaultShipTo_Inactive_c = RuleAction.AddControlSettings(this.oTrans, "ShipTo.Inactive_c", controlSettings1Default);
RuleAction[] ruleActions = new RuleAction[] {defaultShipTo_Inactive_c};
// Create RowRule and add to the EpiDataView.
RowRule rrCreateRowRuleShipToInactive_cEquals_True_2 = new RowRule("ShipTo.Inactive_c", RuleCondition.Equals, true, ruleActions);
((EpiDataView)(this.oTrans.EpiDataViews["ShipTo"])).AddRowRule(rrCreateRowRuleShipToInactive_cEquals_True_2);
}
And here is the code where I am attempting to combine the two:
private void CreateRowRuleShipToInactive_cEquals_True()
{
// Description: Disable ShipTo Row When Inactive_c is TRUE (except for Inactive_c checkbox)
// Instantiate Default ControlSetting for 2nd RuleAction
ControlSettings controlSettings1Default = new ControlSettings();
controlSettings1Default.SetStyleSetName("Default");
// Specify All RuleActions for RowRule when True
RuleAction[] ruleActions = new RuleAction[] {
RuleAction.AddRowSettings(this.oTrans, "ShipTo", false, SettingStyle.Disabled),
RuleAction.AddControlSettings(this.oTrans, "ShipTo.Inactive_c", controlSettings1Default)
};
// Create RowRule and add to the EpiDataView.
RowRule rrCreateRowRuleShipToInactive_cEquals_True = new RowRule("ShipTo.Inactive_c", RuleCondition.Equals, true, ruleActions);
((EpiDataView)(this.oTrans.EpiDataViews["ShipTo"])).AddRowRule(rrCreateRowRuleShipToInactive_cEquals_True);
}
Note that the combined version applies the first action (disabling the row), but not the second).
Has anyone ever successfully pulled this off?
Warm Regards,
Tony Gardner