Announcements
Hi,
I am needing expert advice on how to write an extension such that I can expose closing dates of Business Central. From what I understand dates in API (APIv2 and ODATA) do not contain any information about closing dates as the type is Edm.Date. After lots of hours looking for a solution, using the source looked promising (CLSINCOME), but not all entries are of this source, with some being general journals. Hence I need to get information in the API about a date being a closing date. This is for historical data as well as current so a solution to calculate and store a new field in a table extension may not work unless I can update all historical data.
So my questions:
Can a query extension do a calculation such as set a entry flag, date := ClosingDate(date)? From what I can see this is a no as queries all flow through to T_SQL.
If a calculated field is displayed on a page, but not stored, can this be sent via an API call to the page?
If I need to store a closing date flag in my data, can run a procedure that would update historical data without breaking any data?
Thank you brains trust.
Regards
Darryn
Hi Darryn
You can not do a sql query against BC cloud.
But a query can be a good option.
And yes, flowfields are supported in the query objects.
Here is some more info around it:
docs.microsoft.com/.../optimize-sql-query-objects-and-performance
Hope this helps you.
Hi Inge. This is Business Central cloud. Can I still do SQL queries? Also, what type would I give the Flow Field. I am using an approach which Josh suggested for Page, but would also explore a Query approach if possible. Can Flowfields be used in queires?
Josh, Thank you for sharing your use and solution. It helped me to be able to understand how to provide a solution. In the end I have done a simple Format of the date including <Closing> and will further process after consuming through the API.
In the SQL database the posting date is a date/time field.
So the difference for a normal date and the closing date is the time you see in that field.
Normal dates have one time, closing date has another timestamp for the same date.
So you can query them from the SQL server.
And yes you can build a API that returns the value of a flowfield. You just need to make sure you do a clacfields on them in the API code.
A very different topic but it should show that having a procedure associated to a field in an api page can return simple or complex types: joshanglesea.wordpress.com/.../
Prior-Year entry is another field that could help with filtering
André Arnaud de Cal...
294,125
Super User 2025 Season 1
Martin Dráb
232,871
Most Valuable Professional
nmaenpaa
101,158
Moderator