Webservice to Business Central – Challenge

Offering business central webservices to the world is made easy in this ERP system. Offering fast, reliable webservices is somewhat more challenging.

When you first start with webservices, and a customer ask the question: ‘I have and android app with which I pick articles for a weborder. When the weborder is picked completely on de device, I want to send the info to Business Central, and post and print immediately, so I can put the printed invoice in the box, and a label on the box. We did just that.
(It’s a little more complicated in Nav terms… register a pick, post a warehouse shipment, post a sales shipment and generated the label, post an invoice and print it… at the correct workplace of the device user but for terms of simplicity this is ignored.)
But then some strange things start happening… multiple devices do this simultaneous on picks on the same warehouse shipment, etc… And online users also to things. So locking and deadlock issues occur.

And fixing those took lot more time than initially expected.

So be careful and think deeply on how the webservices will be used in the multi-user world. A device user has no Business Central page on which he can take action in a simple manner.


30+ year programming experience, and still…

Creating a programming error still is simple, and AI isn’t helping me yet.

I develop software for Microsoft Business Central, in a programming language called C/AL (and in de current version this is changed to AL).

Today in a hurry, bugfixing job, I introduced a new error. The code was more than one page long, and I used a for loop with a local variable _i.
And then I nested two for loops…

for _i := 0 to n do begin

// … a bunch of code for the rest of the page
for _i := 0 to m do begin
//create a record and insert into the database
// and m begin typically begin 1 or 2 and n going to 40 or so.

And so I created an infinite loop, for the first time in years.
In C/AL this was inside a transaction, so the table got locked, users complained, and I was able to kill the process. But it had to rollback the transaction. And it already contained +3.5 million records before the message reached us.

And although this is legit coding (or how should the compiler know?), reusing _i in a second inner loop.
With all AI stuff currently available, I hope for a compiler warning at least.