Why API Templates Don't Work on Business Central Custom API Pages
API templates in Business Central only work with specific standard API pages because custom API pages lack the ProcessNewRecordFromAPI function call in their OnInsertRecord trigger. To make templates work on custom API pages, you must add this function call and register fields using the TempFieldSet mechanism.
Read it hereOpen in Claudetag-blogger-com-1999-blog-1492436440038408053-post-1160169849126032090--7f7e64325d.md
post Mohana's Dynamics NAV & BC blog
"API templates can only be set up with the following API pages: contacts, countriesRegions, currencies, customers, employees, itemCategories, paymentMethods, paymentTerms, shipmentMethods, unitsOfMeasure, and vendors."
Key points
- API templates are built-in configuration features that pre-populate fields on new records created via API POST calls, but only 11 standard pages support them out of the box.
- Custom API pages and the Resource API page don’t have the required ProcessNewRecordFromAPI function hook in their OnInsertRecord trigger, so templates are completely ignored.
- To enable templates on custom API pages, add GraphMgtGeneralTools.ProcessNewRecordFromAPI to the OnInsertRecord trigger and register each field using the TempFieldSet temporary record.
- API caller values always take priority over template values; template fields only apply to fields not explicitly provided in the API request or already set by an earlier template.
- The TempFieldSet record tracks which fields were explicitly set in the API call, preventing templates from overwriting intentional caller-provided values.
Quotes
- “API templates can only be set up with the following API pages: contacts, countriesRegions, currencies, customers, employees, itemCategories, paymentMethods, paymentTerms, shipmentMethods, unitsOfMeasure, and vendors.” (Establishes the strict limitation that only these 11 standard pages support API templates, setting expectations for what configurations are possible.)
- “Without it, the framework has no hook to do anything. The template gets ignored completely.” (Explains the root cause of why custom API pages don’t support templates - the missing ProcessNewRecordFromAPI function call is the critical infrastructure piece.)
- “The API caller always wins. ProcessNewRecordFromAPI only applies a template value if that field is not already in TempFieldSet.” (Clarifies the priority system for template application, ensuring explicit API values are never overwritten by templates.)
AL objects mentioned
As named in the post. A name that matches one object page by exact type and name links to it; the others stay as named.
- api “contacts”
- api “countriesRegions”
- api “currencies”
- api “customers”
- api “employees”
- api “itemCategories”
- api “paymentMethods”
- api “paymentTerms”
- api “shipmentMethods”
- api “unitsOfMeasure”
- api “vendors”
- page 5469 “API Setup”
- codeunit 5465 “Graph Mgt - General Tools”
- table “Field”
Not found in BC28-30: table “Field”.
Context
- Features: API templates, Configuration templates, OnInsertRecord trigger, ProcessNewRecordFromAPI function, TempFieldSet tracking, Field registration, Custom API pages, API field priority
Source: Mohana’s Dynamics NAV & BC blog, community blog. Summary, key points and quotes are derived (CONTENT-NOTICE.md); read the original for the full text.