Hi Readers,
Sorry for the delay on next article in API Series for NAV 2018. I exactly forgot about that I didn't complete this series.
Thank you all who requested for this article. Hope this article continues from that.
We already have four posts about NAV 2018 API listed below -
API Part 1
API Part 2 - Configure API
API Part 3 - Consuming API
API Part 4 - Develop a Custom API.
In this article, we will see how we can add Page External Item Entity in the API Web Service Page. After adding External Item Entity in list we will be able to consume ExtItem API Page.
Let's create a New custom Codeunit "Graph Mgt - External Item" that we will use for adding functions which are required to publish New API Page.
To Publish New Page in API, we don't need to modify any base object. Microsoft has added Required Publisher in Base NAV Code to publish new API's.
We need to subscribe to three Published Events -
Event 1 - ApiSetup.
Event 2 - OnGetPredefinedIdValue.
Event 3 - OnUpdateReferencedIdField.
We will Create Three Subscribers in New Codeunit to Subscribe above Listed Events -
Subscriber 1 - HandleApiSetup
Event Publisher Object - Codeunit Graph Mgt - General Tools
Event Function - ApiSetup
Subscriber 2 - HandleGetPredefinedIdValue
Event Publisher Object - Codeunit Integration Management
Event Function - OnGetPredefinedIdValue
Subscriber 3 - HandleUpdateReferencedIdFieldOnItem
Event Publisher Object - Codeunit Integration Management
Event Function - OnUpdateReferencedIdField
Additionally Create a Function UpdateIntegrationRecords with one parameter like - OnlyItemsWithoutId of Type Boolean.
Let's Start adding code to these functions and subscribers.
Subscriber 1 - HandleApiSetup.
This Subscriber will call the Newly Created Function "UpdateIntegrationRecords".
Subscriber 2 - HandleGetPredefinedIdValue
This Subscriber will check that API is already Configured in the database using Integration API action in Page API Setup.
(Discussed in Article Microsoft Dynamics NAV 2018 - API Part 2 - Configure API.)
Subscriber 3 - HandleUpdateReferencedIdFieldOnItem
This Subscriber will check and update Field ID Value if changes in the source table.
Function UpdateIntegrationRecords
This function (Which is called by First Subscriber) insert or modify Integration Record. With Record in Integration Record then it will be ready to publish as API.
Hope you find the information useful and Complete API Development.
Next article we will try to see a demo of how we add this Custom API and will try to use it.
Let me know your views.
Regards,
Saurav Dhyani
www.sauravdhyani.com
Sorry for the delay on next article in API Series for NAV 2018. I exactly forgot about that I didn't complete this series.
Thank you all who requested for this article. Hope this article continues from that.
We already have four posts about NAV 2018 API listed below -
API Part 1
API Part 2 - Configure API
API Part 3 - Consuming API
API Part 4 - Develop a Custom API.
In this article, we will see how we can add Page External Item Entity in the API Web Service Page. After adding External Item Entity in list we will be able to consume ExtItem API Page.
Let's create a New custom Codeunit "Graph Mgt - External Item" that we will use for adding functions which are required to publish New API Page.
To Publish New Page in API, we don't need to modify any base object. Microsoft has added Required Publisher in Base NAV Code to publish new API's.
We need to subscribe to three Published Events -
Event 1 - ApiSetup.
Event 2 - OnGetPredefinedIdValue.
Event 3 - OnUpdateReferencedIdField.
We will Create Three Subscribers in New Codeunit to Subscribe above Listed Events -
Subscriber 1 - HandleApiSetup
Event Publisher Object - Codeunit Graph Mgt - General Tools
Event Function - ApiSetup
Subscriber 2 - HandleGetPredefinedIdValue
Event Publisher Object - Codeunit Integration Management
Event Function - OnGetPredefinedIdValue
Subscriber 3 - HandleUpdateReferencedIdFieldOnItem
Event Publisher Object - Codeunit Integration Management
Event Function - OnUpdateReferencedIdField
Additionally Create a Function UpdateIntegrationRecords with one parameter like - OnlyItemsWithoutId of Type Boolean.
Let's Start adding code to these functions and subscribers.
Subscriber 1 - HandleApiSetup.
This Subscriber will call the Newly Created Function "UpdateIntegrationRecords".
Subscriber 2 - HandleGetPredefinedIdValue
This Subscriber will check that API is already Configured in the database using Integration API action in Page API Setup.
(Discussed in Article Microsoft Dynamics NAV 2018 - API Part 2 - Configure API.)
Subscriber 3 - HandleUpdateReferencedIdFieldOnItem
This Subscriber will check and update Field ID Value if changes in the source table.
Function UpdateIntegrationRecords
This function (Which is called by First Subscriber) insert or modify Integration Record. With Record in Integration Record then it will be ready to publish as API.
Hope you find the information useful and Complete API Development.
Next article we will try to see a demo of how we add this Custom API and will try to use it.
Let me know your views.
Regards,
Saurav Dhyani
www.sauravdhyani.com
Thanks for the comment @Dlmusics.
ReplyDeleteWaiting for part 6! Grateful so far.
ReplyDeleteHi, thank you for the comment. I am no longer using BC 14, but if you are interested, I can do a series on BC API as they have changed. Please let me know.
Deletei have
ReplyDeleteHi please refer this YouTube playlist -
Deletehttps://www.youtube.com/playlist?list=PL2-PuYsxlF1dpqpRdHUbOtpsbrecuY1wR
** This series covers all regarding standard API's. Let me know if you have any questions.