Event After Data Displayed on Form

Is there an event that is fired after data is displayed on the form? I need to ask the user a question when a sales order is loaded and the data has been displayed. I would normally store the current order number and fire the event on EpiViewNotification Initialize when the order number changes. This fires before the data is displayed on the screen. There is a second EpiViewNotification Initialize event after the data is displayed, but counting on it being the second init after an order changes sounds like a bad idea.

AfterAdapterMethod you should be able to capture GetByID. I usually create a global variable hasXyzBeenShown and I set it to true after I capture the first GetByID.

Second way a Custom Row Rule with a Custom Condition.

I usually like the AdapterMethod, since I know exactly when it fires.

Here’s the order of events:

ordAdapter:AfterAdapter:GetByID
ordAdapter:AfterAdapter:InvoiceExists
OrderHed:EpiViewNotification:Initialize - dataview and oTrans has the new order number.

Data Displayed on Screen - Question needs to appear after this.

OrderHed:EpiViewNotification:Initialize

I guess my question would be, why does it have to happen when the data is visible.

Then I would try the AfterRowChange or AfterListChange Event, fires less than the Notification.

AfterListChange fires before the data is visible.
AfterRowChange doesn’t fire at all.

They are being asked to validate the tax exempt status of the ship to that hasn’t been validated before. Normally the question appears when the ship to is changed, but on a quote that is converted to an order it needs to appear when the order is loaded. The confusing time is if an order is already loaded and the order number changes the question will display about the new order with the old order still in the background.

I see…

I was going to suggest

case "GetByID":
   EpiDataView dv = this.oTrans.Factory("OrderHedList");
   EpiMessageBox.Show("Hi " + dv.dataView[dv.Row]["OrderNum"].ToString());
   break;

I like to use RowRules, you can create a simple RowRule via Wizard to trigger when OrderNum Changes or ShipTo ID Changes (so you can fire it on load as well as on change)…

Then you can modify the Wizard RowRule to your Custom Rule, Custom Action…

Also Epicor lets you save the result set (aka that it ran already, you could prob store the ShipToID)

// Set
RuleAction.SaveRuleResult(this.oTrans, "OrderHed.idxConsInv_c", "MyKeyName"), // Save Condition Result in this Bag

// Read
((EpiDataView)(this.oTrans.EpiDataViews["OrderHed"])).RuleKeys["MyKeyName"];

You could check that in your Custom Condition and see if it already has been “evaluated”. If not, set it in the Custom Action.

Full Example Code:

// Mix Custom Action with Regular Actions
private void CustomRules()
{
	RuleAction[] ruleActions = new RuleAction[] {
			RuleAction.AddControlSettings(this.oTrans, "OrderHed.idxConsInv_c", SettingStyle.ReadOnly),
			RuleAction.SaveRuleResult(this.oTrans, "OrderHed.idxConsInv_c", "MyKeyName"), // Save Condition Result in this Bag
			RuleAction.SetColumnValue(this.oTrans, "OrderHed.idxConsInv_c", false)
	};

	RowRule rr = new RowRule("OrderHed.CustNum", new RowRuleConditionDelegate2(this.isCustomerAllowedToDoX), "OrderHed.idxConsInv_c", ruleActions);

	// Mix Custom Action with Regular
	rr.SetRowRuleActionDelegate2(new RowRuleActionDelegate2(this.ShowMsgBox_CustomRuleAction), null);

	((EpiDataView)(this.oTrans.EpiDataViews["OrderHed"])).AddRowRule(rr);
}


private bool isCustomerAllowedToDoX(Ice.Lib.ExtendedProps.RowRuleDelegateArgs args)
{
	bool disable = true;
	bool currentSetting = Convert.ToBoolean(args.Arg2);
	string whereClause = string.Format("CustNum = '{0}'", Convert.ToString(args.Arg1));

	using(Ice.Proxy.Lib.BOReaderImpl _bor = WCFServiceSupport.CreateImpl<Ice.Proxy.Lib.BOReaderImpl>((Ice.Core.Session)oTrans.Session, zEpicor.ServiceModel.Channels.ImplBase<Ice.Contracts.BOReaderSvcContract>.UriPath))
	{
		System.Data.DataSet ds = _bor.GetList("Erp:BO:Customer", whereClause, "Company, CustNum, idxConsInv_c");

		if (ds != null && ds.Tables[0].Rows.Count > 0) {
			disable = Convert.ToBoolean(ds.Tables["CustomerList"].Rows[0]["idxConsInv_c"]) == false;
		}
	}

	return disable;
}

private void ShowMsgBox_CustomRuleAction(Ice.Lib.ExtendedProps.RowRuleDelegateArgs args)
{
	//bool ruleResult = ((EpiDataView)(this.oTrans.EpiDataViews["OrderHed"])).RuleKeys["MyKeyName"];

	if (Convert.ToBoolean(args.Arg2)) {
		EpiMessageBox.Show("Consolidated Invoice has been unchecked. The Selected Customer is not configured for Consolidation.",
			EpiString.GetString("Warning"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
	}
}
1 Like

I think pretty much all of the epicor hook on events are before the ui paint is run. You might have to do something dirty to make this work. Anything that can trigger after paint but I doubt it will be an epicor hook, but a field event instead. Look up MSDN for textbox and see if there is any event there you could maybe rely on?