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

API Issue when other page part exists in page

(0) ShareShare
ReportReport
Posted on by 105
page 80140 "API Sales Order"
{
    PageType = API;

    APIVersion = 'v1.0';
    APIPublisher = 'bcAPI';
    APIGroup = 'Sales';

    EntityCaption = 'SalesOrder';
    EntitySetCaption = 'SalesOrder';
    EntityName = 'salesOrder';
    EntitySetName = 'salesOrder';

    ODataKeyFields = SystemId;
    SourceTable = "Sales Header";

    Extensible = false;
    DelayedInsert = true;

    layout
    {
        area(content)
        {
            repeater(Group)
            {
                field(orderId; Rec.SystemId)
                {
                    Caption = 'Id';
                    Editable = false;
                }
                field(documentType; Rec."Document Type")
                {
                    Caption = 'Document Type', Locked = true;
                }
                field(docNo; Rec."No.")
                {
                    Caption = 'Document No', Locked = true;
                }
                field(customerNo; Rec."Sell-to Customer No.")
                {
                    Caption = 'Customer No', Locked = true;
                }
                field(contactName; Rec."Sell-to Contact")
                {
                    Caption = 'Contact Name', Locked = true;
                }
                field(orderDate; Rec."Order Date")
                {
                    Caption = 'Order Date', Locked = true;
                }
                field(documentDate; Rec."Document Date")
                {
                    Caption = 'Document Date', Locked = true;
                }
                field(postingDate; Rec."Posting Date")
                {
                    Caption = 'Posting Date', Locked = true;
                }
                field(externalDocNo; Rec."External Document No.")
                {
                    Caption = 'External Document No.', Locked = true;
                }
                field(yourReference; Rec."Your Reference")
                {
                    Caption = 'Internal Reference No', Locked = true;
                }
                part(salesOrderLines; "API Sales Order Lines")
                {
                    Caption = 'Order Lines';
                    EntityName = 'salesOrderLine';
                    EntitySetName = 'salesOrderLines';
                    SubPageLink = SystemId = field(Id);
                    // SubPageLink =  "Document Type" = field("Document Type"), "Document No." = field("No.");
                }
            }
        }
    }
page 80141 "API Sales Order Lines"
{
    PageType = API;

    APIVersion = 'v1.0';
    APIPublisher = 'bcAPI';
    APIGroup = 'Sales';

    EntityCaption = 'SalesOrderLine';
    EntitySetCaption = 'SalesOrderLines';
    EntityName = 'salesOrderLine';
    EntitySetName = 'salesOrderLines';

    ODataKeyFields = SystemId;
    SourceTable = "Sales Line";

    Extensible = false;
    DelayedInsert = true;

    layout
    {
        area(content)
        {
            repeater(Group)
            {
                field(salesLineid; Rec.SystemId)
                {
                    Caption = 'Id';
                    Editable = false;
                }
                field(documentType; Rec."Document Type")
                {
                    Caption = 'Document Type', Locked = true;
                }
                field(docNo; Rec."Document No.")
                {
                    Caption = 'Document No', Locked = true;
                }
                field(docLineNo; Rec."Line No.")
                {
                    Caption = 'Document Line No.', Locked = true;
                }
                field(lineType; Rec.Type)
                {
                    Caption = 'Line Type', Locked = true;
                    trigger OnValidate()
                    begin
                        if Rec.Type <> Rec.Type::Item then
                            Error('Line Type must be Item');
                    end;
                }
                field(lineTypeNo; Rec."No.")
                {
                    Caption = 'Line Type No.', Locked = true;
                }
                field(lineDescription; Rec.Description)
                {
                    Caption = 'Line Description', Locked = true;
                }
                field(unitMeasure; Rec."Unit of Measure Code")
                {
                    Caption = 'Unit of Measure Code', Locked = true;
                }
                field(quantity; Rec.Quantity)
                {
                    Caption = 'Quantity', Locked = true;
                }
                field(unitPrice; Rec."Unit Price")
                {
                    Caption = 'Unit Price', Locked = true;
                }
            }
        }
    }
}
When
  • Suggested answer
    YUN ZHU Profile Picture
    78,978 Super User 2025 Season 1 on at
    RE: API Issue when other page part exists in page

    Hi, Here is a good example that I hope will give you some hints.

    https://www.kauffmann.nl/2020/07/01/deep-insert-with-business-central-apis-part-2/

    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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,025 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,837 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans