“What if I could replicate a table to a system in an entirely different database with a different language in an entirely different OS evenly?”
Wondered what I could do with webhooks which wasn’t just a standard use case. This post isn’t a how-to for creating custom API pages in AL or how webhooks work, other people have done this and they are way better at explaining it than me.
The flow I wanted:
- Add generic Business Central AL extension, which exposes the installed APIs and the Field table. This is the main, it will not expose any data tables itself, but will be used to handle the communication.
- Add extension with custom API pages for the tables needing replication. (In this example it will contain the table also, but normally not.)
- Server (called CopyCat) will call the main extension (ALleyCat) and get a list of all API pages within a specific APIGroup (BadSector) and their table structure.
- CopyCat will connect to a secondary database and create tables.
- CopyCat will copy all records.
- CopyCat will subscribe via webhooks for further changes.
- Each webhook response is just a record ID and the change type, ex. Updated or Deleted. So CopyCat will either request new/updated record or delete if needed.
Will keep a list of new or modified records in an array and only request a predefined records pr. sec, so the main service-tier won’t be overloaded. - Periodic requests for table changes in BC and if new fields are detected, they are added to the table.