web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

How can i use local procedure in Query Type API.

(1) ShareShare
ReportReport
Posted on by 163
Hi All,
I am using On-Prem Business Central.
I am writing one query API to fetch item details from item table along the sales price from sales price list according to the product Id.
and there i need to call a procedure on the field in query column, but it shows it is not possible.
Below is my code : 
query 50112 GetAllItemsDetails
{
    QueryType = API;
    APIPublisher = 'QueryV1';
    APIGroup = 'QueryGroup';
    EntityName = 'Item';
    EntitySetName = 'Items';
    elements
    {
        dataitem(ItemDetails; Item)
        {
            column(ItemNo; "No.")
            {
            }
            column(Name; Description)
            {
            }
            column(Inventory; Inventory)
            {
            }
            column(PictureId; Picture)
            {
            }
            column(Base_Unit_Price; "Unit Price")
            {
            }
            column(Details; GetDetails())   // This i want to do. but not able to achieve.
            {
            }
            dataitem(Price_List_Line; "Price List Line")
            {
                DataItemLink = "Asset No." = ItemDetails."No.";
                SqlJoinType = LeftOuterJoin;
                column(Unit_Price; "Unit Price")
                {
                }
            }
        }
    }
procedure GetDetails():Text
begin
// my logic
end
Does anyone have any idea about this. How we can achive this by Query API.
If anyone have any code snip please share.
Thanks for your Help.
I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    95,597 Super User 2025 Season 2 on at
    Unfortunately, you cannot add any procedures to Query. You need to use page to do this.
     
    Thanks.
    ZHU
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    20,439 Super User 2025 Season 2 on at

    You can't call a procedure directly in a query in Business Central. To achieve this, either:
    Use a codeunit or report to apply your logic after retrieving the data via the query.
    Add a calculated field in the table and reference it in the query.

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,010

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,270 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,085 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans