April 09, 2025

How to trigger Business event using x++ code

Hi Folks, 

I recently faced issue where PO confirmation business event was not triggering and failing my interface. Issue was whenever after first PO confirmation if user make change to PO header delivery date or cancellation date  and reconfirm the PO, it wont trigger the respective Business event. 

[Although there are different reason why business event is not considering this change, while if I make any financial changes like qty, line addition, tax etc, it works fine]

Ok lets see now how I can call a business event from code, 

To trigger a business event in X++ code, you need to create a business event contract, an event handler class, and then trigger the event from your X++ code by using the BusinessEvent::newFromTable() and businessEvent.send() methods. (Also,  configure the event in the business event catalog if its not configured)

1. Create a Business Event Contract:
Purpose: Defines the data that will be sent with the business event. For reference check  CustFreeTextInvoicePostedBusinessEventContract.


 2. Create an Event Handler Class:
Purpose: Handles the event when it's triggered, allowing you to perform actions based on the event.
For reference check CustTable_BusinessEvent_EventHandler

3. Trigger the Business Event from X++ Code:
Purpose: Use the BusinessEvent::newFromTable() and businessEvent.send() methods to trigger the event.


here is complete code sample, 





-Harry Follow us on Facebook to keep in rhythm with us. https:fb.com/theaxapta

March 17, 2025

Update admin user in Dev box

Old is gold,


MS removed admin user provising tool, but there is an old way where you can still add your user as admin, 

Go to the VM and open SQL management Studio, 

Step 1: Find admin user rec id in USERINFO table, 

select  * from USERINFO

Step 2: Get SID from earlier Database for your user

select  * from USERINFO
where RECID = 53755554576


Step 3: Update new Database with below query 

update USERINFO
set NETWORKALIAS = 'deepak.agarwal@theaxapta.com',
sid = 'S-1-19-18-####-####-####5192'
where RECID = 53755554576


Make sur eof choosing right Database of each query and use the right recid and other values. 


-Harry Follow us on Facebook to keep in rhythm with us. https:fb.com/theaxapta