/// <summary> /// This is a BusinessEventContract class for Customer /// </summary> [DataContract] class VKCustTableChangedBusinessEventContract extends BusinessEventsContract { SysAppCRUDOperation action; CustAccount custAccount; DataAreaId dataAreaId; private void initialize(CustTable _custTable, SysAppCRUDOperation _action) { custAccount = _custTable.AccountNum; dataAreaId = _custTable.DataAreaId; action = _action; } /// <summary> /// Create new VKCustTableChangedBusinessEventContract from CustTable and action /// </summary> /// <param name = "_custTable">CustTable table</param> /// <param name = "_action">Action</param> /// <returns>a new VKCustTableChangedBusinessEventContract</returns> public static VKCustTableChangedBusinessEventContract newFromCustTable(CustTable _custTable, SysAppCRUDOperation _action) { VKCustTableChangedBusinessEventContract contract = new VKCustTableChangedBusinessEventContract(); contract.initialize(_custTable, _action); return contract; } protected void new() { } [DataMember('CustAccount'), BusinessEventsDatamember("CustAccount")] public CustAccount parmCustAccount(CustAccount _custAccount = custAccount) { custAccount = _custAccount; return custAccount; } [DataMember('Action'), BusinessEventsDatamember("Action")] public SysAppCRUDOperation parmAction(SysAppCRUDOperation _action = action) { action = _action; return action; } [DataMember('DataAreaId'), BusinessEventsDatamember("DataAreaId")] public DataAreaId parmDataAreaId(DataAreaId _dataAreaId = dataAreaId) { dataAreaId = _dataAreaId; return dataAreaId; } }
/// <summary> /// This is a BusinessEvent class for Customer /// </summary> [BusinessEvents(classStr(VKCustTableChangedBusinessEventContract), "Customers CU", "Event for create, update", ModuleAxapta::General)] class VKCustTableChangedBusinessEvent extends BusinessEventsBase { private CustTable custTable; SysAppCRUDOperation action; /// <summary> /// Create new VKCustTableChangedBusinessEvent from CustTable and action /// </summary> /// <param name = "_custTable">CustTable table</param> /// <param name = "_action">Action</param> /// <returns>a new VKCustTableChangedBusinessEvent</returns> public static VKCustTableChangedBusinessEvent newFromCustTable(CustTable _custTable, SysAppCRUDOperation _action) { VKCustTableChangedBusinessEvent businessEvent = new VKCustTableChangedBusinessEvent(); businessEvent.parmAction(_action); businessEvent.parmCustTable(_custTable); return businessEvent; } private CustTable parmCustTable(CustTable _custTable = custTable) { custTable = _custTable; return custTable; } private SysAppCRUDOperation parmAction(SysAppCRUDOperation _action = action) { action = _action; return action; } protected void new() { } [Wrappable(true), Replaceable(true)] public BusinessEventsContract buildContract() { return VKCustTableChangedBusinessEventContract::newFromCustTable(custTable, action); } }
/// <summary> /// Extension class for Custtable table /// </summary> [ExtensionOf(tableStr(CustTable))] final class VKCustTable_Extension { public void insert(DirPartyType _partyType, Name _name,boolean _updateCRM) { next insert(_partyType, _name, _updateCRM); if (BusinessEventsConfigurationReader::isBusinessEventEnabled(classStr(VKCustTableChangedBusinessEvent)) && !CustTable::vkSkipByUserFilter()) { VKCustTableChangedBusinessEvent::newFromCustTable(this, SysAppCRUDOperation::Create).send(); } } public void update(boolean _updateSmmBusRelTable, boolean _updateParty) { next update(_updateSmmBusRelTable, _updateParty); if (BusinessEventsConfigurationReader::isBusinessEventEnabled(classStr(VKCustTableChangedBusinessEvent)) && !CustTable::vkSkipByUserFilter()) { VKCustTableChangedBusinessEvent::newFromCustTable(this, SysAppCRUDOperation::Update).send(); } } /// <summary> /// Whether to skip sending business event or not /// </summary> /// <returns>true to skip sending BE</returns> public static boolean vkSkipByUserFilter() { boolean ret = false; // Use there real user id, which will be used for integration to avoid triggering update business event when external system updates the entity if ('Admin' == curUserId()) { ret = true; } return ret; } }
DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.
Authors are allowed to set their own AdSense units and "buy me a coffee" link.
Join us.