Quantcast
Channel: Dynamics 365 Business Central/NAV User Group
Viewing all articles
Browse latest Browse all 11285

Blog Post: Generating AL objects from JSON

$
0
0
As interacting with WebServices, especially JSON/REST based WebServices, becomes more and more important, it was very good to see that the new NAV dev environment made it quite easy to do exactly that a couple of releases ago. After reading AJ Kauffmann’s excellent blog post on that topic , I had the idea to auto-generate that code based on a JSON file, so that you no longer need to write a single line of code to get a working base structure. With release 2.3.0 of my VS Code extension this is now possible! For the following steps I assume that you already have an AL project in place. The hello world one, that you can get with command „AL: Go!“ works fine as well. The workflow after installing my extension is as follows: Hit Ctrl+Shift+P 1 and enter „ALR gen“. This will get you the command to call my generation task as VS Code supports partial search in the command palette 2 . Hit enter to start it It will now ask you for a URL where it can get the JSON file you want to use. Using a slightly different URL than in AJ’s post you could get the Github issues on NAV on Docker: https://api.github.com/repos/Microsoft/nav-docker/issues Tell it how you want to name the entity you work with in D365, in our example maybe „Issues“ Very quickly you should get three new files containing a Codeunit with the refresh logic, a Table to handle the data and a Page to display it. Save them to whatever naming convention works for you As you already have my extension installed, go to the Page you just created and hit Shitf+Alt+P. This will publish your project and run the Page. You should see an empty list page with an action to refresh the data. Click that action, wait a second and then you should see the data, in our example the NAV on Docker issues The whole process should look like this: If you run into problems or have ideas how to improve the extension, please let me know on Github . If you like the extension, rate it or even write a review. Thanks a lot to AJ Kauffmann for allowing me to build on his code! The post Generating AL objects from JSON appeared first on Axians Infoma .

Viewing all articles
Browse latest Browse all 11285

Trending Articles