Hello,
Is it possible to call functions after API request?
My case:
I prepared API page for Business Central and now I need to call function after the call is send. I tired to use triggers: OnClosePage, OnQueryClosePage but those two are not working. Is there any other possibility to call function after API request in BC?
Hi, I have a different scenario:
When I call my API, I have to skip all onValidate triggers in the table because I always get all the errors related to empty fields even if they are all filled.
So I created an event in the table that uses the standard "isHandled" method, but I'm using the User Setup table to set a custom boolean field (isApi).
So, when the OnOpenPage trigger (in the page API) is executed, I set the isApi field in User Setup to true.
So far, it works. My problem is setting it back to false when the call is ended.
I tried OnClosePage and OnQueryClosePage too, but the field is always true now; even if the page is closed.
Hi, just adding a simple example.
How to run AL procedure in Power Automate (Add custom execute actions)
Hope this helps as well.
Thanks.
ZHU
Thanks you very much Inge.
If you want to perform a posting as part of an API call you should use the bound actions in the API.
You can look here for some examples.
docs.microsoft.com/.../devenv-creating-and-interacting-with-odatav4-bound-action
Hi Inge, thanks for your suggestion. I've tested this posting some inventory adjustment and worked fine.
My api will receipt some other kind of docs like purchase receipts and sales invoice that I will try to posting in the next days.
Why you do not recommend this trigger?
Thanks again.
I would not recommend you to use that trigger for posting.
You should look at some other event or some other way to do your posting.
What is your buisness scenario ?
Hi, I search your post because I have same problem. After some search, I have seen that the event that fire after post request, is the OnBeforeCompanyClose.
Subscribing this event in my cu, I can perform bc post documents.
Thanks for your time, job solution looks like the best option.
It is possible but i would not do it that way.
What i would do is to create a time trigger job in the job queue that every x minutes looks for new records in doc header and then post them. This is because than a failure in your posting will not affect the whole flow of your API.
So separate the insert transaction through the API from the posting process. Allowing potential errors to be handle in what my opinion is a better way.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,802 Super User 2024 Season 2
Martin Dráb 229,133 Most Valuable Professional
nmaenpaa 101,154