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...
Unanswered

API Page (List Part Page) Didn't Return Data

(0) ShareShare
ReportReport
Posted on by 78

Hi Experts,

We are making a API page to post warehouse shipment into posted warehouse shipment and get the new-created posted warehouse shipment lines back together.

The problem is when we called the api, it worked and did post the document, but it didn't return those new-created lines at the same time.

We were wondering if anyone who ran into the same situation, could please tell us how we can fix the table or the page we defined, so we can make the post-call return those new-created lines we want.

 

Thanks!

Here is the response of a post request:

REQUEST POST URL-bcinsider:7048/.../v1.0

/companies(f5a0e7d7-55f9-ea11-bb63-000d3a492461)

/postWhseShips?$expand=postedWhseShipLines

REQUEST BODY

{
    "WhseShipmentNo": "WHSSHIP200040",
    "CreateInvoice": true
}

RESPONSE

{
    "@odata.context": "http://bcinsider:7048/BC/api/TrueCommerce/TRC/v1.0/$metadata#companies(f5a0e7d7-55f9-ea11-bb63-000d3a492461)/postWhseShips/$entity",
    "@odata.etag": "W/\"JzQ0O2sva1g4OW9SYjB1d2QrTDgvNlE2Zm9HOTRiMC9rZUNENXpFR0xDOWtvQlk9MTswMDsn\"",
    "no": 4,
    "WhseShipmentNo": "WHSSHIP200040",
    "CreateInvoice": true,
    "PostedWhseShipmentNo": "P-WHSSHIP200042",
    "PostedSalesShipmentNo": "S-SHPT103067",
    "PostedSalesInvoiceNo": "PS-INV103283",
    "postedWhseShipLines": [] // with no lines returned
}

 

Here is our code:

  • the table defined to post the document
    table 70203602 TRCPostWhseShip
    {
        DataClassification = CustomerContent;
        Permissions = tabledata "Warehouse Shipment Header" = idmr,
            tabledata "Warehouse Shipment Line" = idmr,
            tabledata "Sales Header" = mr,
            tabledata "Sales Line" = mr;
    
        fields
        {
            field(70203500; "No."; Integer)
            {
                DataClassification = CustomerContent;
                AutoIncrement = true;
                Access = Internal;
            }
            field(70203501; WhseShipNo; Code[20])
            {
                DataClassification = CustomerContent;
            }
            field(70203502; "Location Code"; Code[10])
            {
                DataClassification = CustomerContent;
            }
            field(70203503; "Posting Date"; Date)
            {
                DataClassification = CustomerContent;
            }
            field(70203504; "Shipment Date"; Date)
            {
                DataClassification = CustomerContent;
            }
            field(70203505; CreateInvoice; Boolean)
            {
                DataClassification = CustomerContent;
            }
            field(70203506; PostedWhseShipmentNo; Code[20])
            {
                DataClassification = CustomerContent;
            }
            field(70203507; PostedSalesShipmentNo; Code[1024])
            {
                DataClassification = CustomerContent;
                InitValue = '';
            }
            field(70203508; PostedSalesInvoiceNo; Code[1024])
            {
                DataClassification = CustomerContent;
                InitValue = '';
            }
        }
    
        keys
        {
            key(PK; "No.")
            {
                Clustered = true;
            }
        }
    
        var
    
        trigger OnInsert()
        var
            whseShipHeader: Record "Warehouse Shipment Header";
            whseShipLine: Record "Warehouse Shipment Line";
            postedWhseShipHeader: Record "Posted Whse. Shipment Header";
            postedWhseShipLine: Record "Posted Whse. Shipment Line";
            postedInv: Record "Sales Invoice Header";
            postedInvLine: Record "Sales Invoice Line";
    
            cuPostWhseShip: Codeunit "Whse.-Post Shipment";
    
            lstSalesOrderNo: List of [Code[20]];
            lstPostedSalesShipNo: List of [Code[20]];
            lstPostedInvNo: List of [Code[20]];
        begin
            if whseShipHeader.Get(Rec.WhseShipNo) then begin
                whseShipLine.SetRange("No.", Rec.WhseShipNo);
                if whseShipLine.FindSet() then
                    repeat
                        if (whseShipLine."Qty. to Ship" > 0) and (whseShipLine."Qty. to Ship" <= whseShipLine.Quantity) then begin
                            cuPostWhseShip.SetPostingSettings(Rec.CreateInvoice);
                            cuPostWhseShip.Run(whseShipLine);
                        end;
                    until whseShipLine.Next() = 0;
            end;
        end;
    }


  • the api page defined for the table above
    page 70203621 TRCPostWhseShip
    {
        SourceTable = TRCPostWhseShip;
        DelayedInsert = true;
        Permissions = tabledata "TRCPostWhseShip" = rimd, tabledata "Posted Whse. Shipment Header" = idmr;
        PageType = API;
        APIVersion = 'v1.0';
        Caption = 'postWhseShip', Locked = true;
        APIPublisher = 'TrueCommerce';
        APIGroup = 'TRC';
        EntityName = 'postWhseShip';
        EntitySetName = 'postWhseShips';
    
        layout
        {
            area(Content)
            {
                group(General)
                {
                    field(WhseShipmentNo; Rec.WhseShipNo)
                    {
                        ApplicationArea = All;
                    }
                    field(CreateInvoice; Rec.CreateInvoice)
                    {
                        ApplicationArea = All;
                    }
                    field(PostedWhseShipmentNo; Rec.PostedWhseShipmentNo)
                    {
                        ApplicationArea = All;
                    }
                    field(PostedSalesShipmentNo; Rec.PostedSalesShipmentNo)
                    {
                        ApplicationArea = All;
                    }
                    field(PostedSalesInvoiceNo; Rec.PostedSalesInvoiceNo)
                    {
                        ApplicationArea = All;
                    }
                    part(TRCPostedWhseShipLinePart; 70203622)
                    {
                        ApplicationArea = All;
                        Caption = 'postedWhseShipLines', Locked = true;
                        EntityName = 'postedWhseShipLine';
                        EntitySetName = 'postedWhseShipLines';
                        SubPageLink = "No." = field(PostedWhseShipmentNo);
                    }
                }
            }
        }
    }


  • the line page defined as a list part for the api page
    page 70203622 TRCPostedWhseShipLinePart
    {
        SourceTable = "Posted Whse. Shipment Line";
        PageType = ListPart;
        Permissions = tabledata "Posted Whse. Shipment Line" = r;
    
        layout
        {
            area(Content)
            {
                repeater(General)
                {
                    field("No."; Rec."No.")
                    {
                        ApplicationArea = All;
                    }
                    field("Whse Shipment Line No."; Rec."Whse Shipment Line No.")
                    {
                        ApplicationArea = All;
                    }
                    field("Source No."; Rec."Source No.")
                    {
                        ApplicationArea = All;
                    }
                    field("Source Line No."; Rec."Source Line No.")
                    {
                        ApplicationArea = All;
                    }
                    field("Posted Source No."; Rec."Posted Source No.")
                    {
                        ApplicationArea = All;
                    }
                }
            }
        }
    }

Thanks again!

  • Fernando Profile Picture
    Fernando 5 on at
    API Page (List Part Page) Didn't Return Data
    I don't know if this helps you, but what I do is to make the part page the same API type and so it returns the lines.

    Maybe the response just shows the records that you send only, for example I create an API that create a Task and each Task has Activities, inside the table Activity I have a onInsert trigger that creates two activities for the Task when its inserted.
    If I send something like this.

    {
        "taskNo": "task1",
        "description": "Description of task 1"
    }

    The response is. 
    {
        "@odata.context": "http://testcontainer:7048/BC/api/publisherName/apiGroup/v1.0/$metadata#companies(919762b0-9861-ee11-8df4-6045bde9b6e1)/Tasks/$entity",
        "@odata.etag": "W/\"JzE5OzQxMDYyODE2MjY4MDEyMTkzODExOzAwOyc=\"",
        "taskNo": "TASK1",
        "description": "Description of task 1",
        "systemCreatedBy": "8a5e06ad-ce97-4c62-b233-ca8c542bdc1a",
        "listActivities": []
    }

    and if I do a GET request, I receive this.
    {
        "@odata.context": "http://testcontainer:7048/BC/api/publisherName/apiGroup/v1.0/$metadata#tasks",
        "value": [
            {
                "@odata.etag": "W/\"JzE5OzQxMDYyODE2MjY4MDEyMTkzODExOzAwOyc=\"",
                "taskNo": "TASK1",
                "description": "Description of task 1",
                "systemCreatedBy": "8a5e06ad-ce97-4c62-b233-ca8c542bdc1a",
                "listActivities": [
                    {
                        "@odata.etag": "W/\"JzE5OzU1ODI5MDg0MzMxNDIzNzEzODMxOzAwOyc=\"",
                        "TaskNo": "TASK1",
                        "EntryNo": 1000,
                        "Description": "Ejemplo de actividad 1000"
                    },
                    {
                        "@odata.etag": "W/\"JzE5OzczNjczMTQ0NzMwMTYzMDc5NTQxOzAwOyc=\"",
                        "TaskNo": "TASK1",
                        "EntryNo": 2000,
                        "Description": "Ejemplo de actividad 2000"
                    }
                ]
            }
        ]
    }

    If I send the same POST request but with an Activity.
    {
        "taskNo": "task1",
        "description": "Description of task 1",
        "listActivities": [
            {
                "EntryNo": 0,
                "Description": "Activitie 1"
            }
        ]
    }
    I receive this.
    {
        "@odata.context": "http://testcontainer:7048/BC/api/publisherName/apiGroup/v1.0/$metadata#companies(919762b0-9861-ee11-8df4-6045bde9b6e1)/Tasks/$entity",
        "@odata.etag": "W/\"JzE5OzQxMDYyODE2MjY4MDEyMTkzODExOzAwOyc=\"",
        "taskNo": "TASK1",
        "description": "Description of task 1",
        "systemCreatedBy": "8a5e06ad-ce97-4c62-b233-ca8c542bdc1a",
        "listActivities": [
            {
                "@odata.etag": "W/\"JzE5OzExMDM1MjkxNTY5NzQyODQ1ODAxOzAwOyc=\"",
                "TaskNo": "TASK1",
                "EntryNo": 0,
                "Description": "Activitie 1"
            }
        ]
    }
    And when Get the Task show this.
    {
        "@odata.context": "http://testcontainer:7048/BC/api/publisherName/apiGroup/v1.0/$metadata#tasks",
        "value": [
            {
                "@odata.etag": "W/\"JzE5OzQxMDYyODE2MjY4MDEyMTkzODExOzAwOyc=\"",
                "taskNo": "TASK1",
                "description": "Description of task 1",
                "systemCreatedBy": "8a5e06ad-ce97-4c62-b233-ca8c542bdc1a",
                "listActivities": [
                    {
                        "@odata.etag": "W/\"JzE5OzExMDM1MjkxNTY5NzQyODQ1ODAxOzAwOyc=\"",
                        "TaskNo": "TASK1",
                        "EntryNo": 0,
                        "Description": "Activitie 1"
                    },
                    {
                        "@odata.etag": "W/\"JzE5OzU1ODI5MDg0MzMxNDIzNzEzODMxOzAwOyc=\"",
                        "TaskNo": "TASK1",
                        "EntryNo": 1000,
                        "Description": "Ejemplo de actividad 1000"
                    },
                    {
                        "@odata.etag": "W/\"JzE5OzczNjczMTQ0NzMwMTYzMDc5NTQxOzAwOyc=\"",
                        "TaskNo": "TASK1",
                        "EntryNo": 2000,
                        "Description": "Ejemplo de actividad 2000"
                    }
                ]
            }
        ]
    }

    Perhaps you could first create the record and then request with the lines, if an error occurs during the creation of the lines in the onInsert the error is returned in the request.

  • haryadihart Profile Picture
    haryadihart 22 on at
    API Page (List Part Page) Didn't Return Data
    try adding this after your endpoint:
    ?$expand=lines

    lines is your part name in your API Card pages
     
    so, in this case is ?$expand=TRCPostedWhseShipLinePart
     
    it is applied to POST and GET as well
  • MS-01071154-0 Profile Picture
    MS-01071154-0 6 on at
    API Page (List Part Page) Didn't Return Data
    Hey, did you find a solution for that problem? I've got the same right now. But for me it's a GET Request that doesn't return the data from the ListPart.
  • Craig Yu Profile Picture
    Craig Yu 78 on at
    RE: API Page (List Part Page) Didn't Return Data

    Hi,

    Thanks for your reply,

    I did not get the Posted Warehouse Shipment Lines related to the Posted Warehouse Shipment (P-WHSSHIP200042).

    Thanks again.

  • Bilal Haider Profile Picture
    Bilal Haider 232 on at
    RE: API Page (List Part Page) Didn't Return Data

    Hi,

    Are you not getting any lines from Posted Warehouse Shipment Lines or you are not getting the recently Posted Warehouse Shipment Line ?

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... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,430 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans