Business event is a mechanism for detecting and responding to important situations/events in the business process.
Triggering Mechanism for business events: The system sends external signals when specific events occur, such as the full invoicing of a sales order or the completion of a batch job, etc.
Applications of business events in d365 fo: Integrations with other systems via Microsoft Power Automate or custom web services or Logic Apps. Example: Sending alerts to users.
Minimal Performance Impact: Business events ensures efficient operation without burdening the system.
Purpose: Facilitates real-time integration scenarios and automates business processes, hence reducing the need for extensive customization.
Path for business event:
Contract class 1 for business events in d365 fo:
[DataContract]
public final class LSAPIINTSPAPIOrderOrderCallBEContract extends BusinessEventsContract
{
private str ResponseJSON;
private str UniqueID;
private LegalEntityDataAreaId legalEntity;
public static LSAPIINTSPAPIOrderOrderCallBEContract newFromInventTable(LSAPIINTSPAPIOrderOrderCall _LSAPIINTSPAPIOrderOrderCall)
{
var contract = new LSAPIINTSPAPIOrderOrderCallBEContract();
contract.initialize(_LSAPIINTSPAPIOrderOrderCall);
return contract;
}
[DataMember('UniqueID'), BusinessEventsDataMember("UniqueID")]
public str parmUniqueID(str _UniqueID = UniqueID)
{
UniqueID = _UniqueID;
return UniqueID;
}
[DataMember('ResponseJSON'), BusinessEventsDataMember("ResponseJSON")]
public str parmResponseJSON(str _ResponseJSON = ResponseJSON)
{
ResponseJSON = _ResponseJSON;
return ResponseJSON;
}
[DataMember('LegalEntity'), BusinessEventsDataMember("@SYS315616")]
public LegalEntityDataAreaId parmLegalEntity(LegalEntityDataAreaId _legalEntity = legalEntity)
{
legalEntity = _legalEntity;
return legalEntity;
}
private void initialize(LSAPIINTSPAPIOrderOrderCall _LSAPIINTSPAPIOrderOrderCall)
{
ResponseJSON = _LSAPIINTSPAPIOrderOrderCall.ResponseJSON;
UniqueID = _LSAPIINTSPAPIOrderOrderCall.UniqueID;
legalEntity = _LSAPIINTSPAPIOrderOrderCall.DataAreaId;
}
}
Business Event Class 2 for business events in d365 fo:
//LSAPIINTSPAPIOrderOrderCallBusinessEvent
[BusinessEvents(classStr(LSAPIINTSPAPIOrderOrderCallBEContract),
"LSAPIINTSPAPIOrderOrderCall data inserted",
"This business event is triggered when a user inserts data into LSAPIINTSPAPIOrderOrderCall",
ModuleAxapta::ProductInformationManagement)]
public class LSAPIINTSPAPIOrderOrderCallBusinessEvent extends BusinessEventsBase
{
private LSAPIINTSPAPIOrderOrderCall LSAPIINTSPAPIOrderOrderCall;
static public LSAPIINTSPAPIOrderOrderCallBusinessEvent newFromInventTable(LSAPIINTSPAPIOrderOrderCall _LSAPIINTSPAPIOrderOrderCall)
{
LSAPIINTSPAPIOrderOrderCallBusinessEvent businessEvent = new LSAPIINTSPAPIOrderOrderCallBusinessEvent();
businessEvent.parmLSAPIINTSPAPIOrderOrderCall(_LSAPIINTSPAPIOrderOrderCall);
return businessEvent;
}
private void new()
{
}
private LSAPIINTSPAPIOrderOrderCall parmLSAPIINTSPAPIOrderOrderCall(LSAPIINTSPAPIOrderOrderCall _LSAPIINTSPAPIOrderOrderCall = LSAPIINTSPAPIOrderOrderCall)
{
LSAPIINTSPAPIOrderOrderCall = _LSAPIINTSPAPIOrderOrderCall;
return LSAPIINTSPAPIOrderOrderCall;
}
[Wrappable(true), Replaceable(true)]
public BusinessEventsContract buildContract()
{
return LSAPIINTSPAPIOrderOrderCallBEContract::newFromInventTable(LSAPIINTSPAPIOrderOrderCall);
}
}
Now call the class in insert of the table as shown below so that the business events in d365 fo will hit the moment data is inserted in this table
public class LSAPIINTSPAPIOrderOrderCall extends common
{
public void insert()
{
super();
if(this)
{
LSAPIINTSPAPIOrderOrderCall LSAPIINTSPAPIOrderOrderCall;
select * from LSAPIINTSPAPIOrderOrderCall
where LSAPIINTSPAPIOrderOrderCall.RecId == this.RecId;
LSAPIINTSPAPIOrderOrderCallBusinessEvent::newFromInventTable(LSAPIINTSPAPIOrderOrderCall).send();
}
}
}
After building and syncing
Now for the last step to be performed for finalizing business events in d365 fo
Go to Business events and Rebuild the business event catalog
To get the JSON: D365 business events return JSON
Need help? Connect Atul
- D365 Data entitiy Insert method COC - October 30, 2024
- D365 Joins - October 16, 2024
- D365 Find method and Exist method - October 9, 2024