Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

How can i use local procedure in Query Type API.

Posted on by 140
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.
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    Khushbu Rajvi. 4,615 on at
    How can i use local procedure in Query Type API.

    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.

     

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,698 Super User 2024 Season 2 on at
    How can i use local procedure in Query Type API.
    Unfortunately, you cannot add any procedures to Query. You need to use page to do this.
     
    Thanks.
    ZHU

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans