When creating an API page, the fields contained in the primary key for the table in question are always added, no matter if you set visible = false or use $expand (omitting unwanted fields).
According to Jens Møller-Pedersen (MS development center) whom I spoke to at the recent TechDays this is due to being able to use paging.
But in some cases the key fields are of no use and are unwanted and the responsibility for conforming to use paging should be the repsonsibility of the developer. For example making a page based on a temporary table, using a integer no. to separate records, but where the value is of no use or relevance for the resulting data.
I therefor suggest that one (or more) of these solutions being implemented:
- A property on the page - SuppressAutoKeyFields
- Property on field - visble = false will omit the field from the resulting page
- $expand will only include the fields listed - included omitting not mentioned fields.
Business Central Team (administrator)
Thank you for this suggestion! Currently this is not on our roadmap. We are tracking this idea and if it gathers more votes and comments we will consider it in the future. Best regards, Business Central Team