Skip to main content

Notifications

Community site session details

Community site session details

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

AL script Create Warehouse Receipt Lines

(0) ShareShare
ReportReport
Posted on by

Hello!
We are developing AL scripts to POST Warehouse receipt\lines to MBC.

Warehouse receipts POST Api Page works fine


We are trying to develop AL script to POST Warehouse Receipt Lines.
We use following AL script for that (API Page)

page 50213 ApiPageWarehouseReceiptLine
{
PageType = API;
Caption = 'ApiPageWarehouseReceiptLine';
APIPublisher = 'Testing';
APIGroup = 'TestApi';
APIVersion = 'v1.0';
EntityName = 'WarehouseReceiptLine';
EntitySetName = 'WarehouseReceiptLine';
SourceTable = "Warehouse Receipt Line";
DelayedInsert = true;
DeleteAllowed = true;
InsertAllowed = true;
ModifyAllowed = true;

layout
{
area(Content)
{
repeater(GroupName)
{
field(number; "No.")
{
Caption = 'number';
}
field(binCode; "Bin Code")
{
Caption = 'binCode';
}
field(sourceDocument; "Source Document")
{
Caption = 'sourceDocument';
}
field(dueDate; "Due Date")
{
Caption = 'dueDate';
}
field(lineNo; "Line No.")
{
Caption = 'lineNo';
}
field(qtyToReceive; "Qty. to Receive")
{
Caption = 'qtyToReceive';
}
field(quantity; Quantity)
{
Caption = 'quantity';
}
field(sourceNo; "Source No.")
{
Caption = 'sourceNo';
}
field(sourceLineNo; "Source Line No.")
{
Caption = 'sourceLineNo';
}
}
}
}
}

When we filled in property SourceDocument we got error "Control 'sourceDocument' is read-only"
When we leave it empty we got error: "Source Document must be equal to 'Purchase Order' in Warehouse Receipt Line: No.={Number}, Line No.=0. Current value is ' '"

Can someone please tell us how we can POST Warehouse Receipt Lines to MBC via AL?

  • mishaln Profile Picture
    15 on at
    RE: AL script Create Warehouse Receipt Lines

    Hello  ,

    Did you manage to solve this? Appreciate your help :) 

    Thanks,

    Mishal

  • Community Member Profile Picture
    on at
    RE: AL script Create Warehouse Receipt Lines

    Dear, Suresh

    thanks for your reply

    Codeunit with subscription to event OnBeforeInsertEvent not help

    I already tried to do the same for OnBeforeValidateEvent,but no luck

    API call still gives Application_FieldValidationException Source Document must be equal to 'Purchase Order' in Warehouse Receipt Line: No.={Number}, Line No.=0. Current value is ' ' error

    Maybe it's possible to call "Create Whse. Receipt" action from Purchase Order page using bound\unbound action. i can't find this action at Purchase Order page in AL

    Maybe you can suggest how i can to it?

    Many thanks in advance

  • Verified answer
    Suresh Kulla Profile Picture
    47,789 on at
    RE: AL script Create Warehouse Receipt Lines

    You just need to create a codeunit and subscribe to that event you don’t need tableextension

  • Community Member Profile Picture
    on at
    RE: AL script Create Warehouse Receipt Lines

    Thanks for your response Suresh

    Can you tell please, is it correct that we need to add separate table extension with subscription to event, like this?

    tableextension 50214 WarehouseReceiptLineSrcDocExt extends "Warehouse Receipt Line"

    {

       trigger OnBeforeInsert();

       begin

           if "Source Document" = "Warehouse Activity Source Document".FromInteger(0) then begin

               "Source Document" := "Warehouse Activity Source Document".FromInteger(5);

           end;

       end;

    }

  • Suggested answer
    Suresh Kulla Profile Picture
    47,789 on at
    RE: AL script Create Warehouse Receipt Lines

    The Source Document is set to not editable on the table and that is why you are getting that error, one thing you could try is to subscribe to the OnBeforeInsertTrigger event of the Warehouse Receipt Line table and set the value of the Source Document when it is blank.

  • Suggested answer
    JAngle Profile Picture
    95 on at
    RE: AL script Create Warehouse Receipt Lines

    No odatakeyfields property set. The primary key of the table is “No.", "Line No." so you’d need to follow that for any CRUD actions to function

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

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

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 1,234

#2
YUN ZHU Profile Picture

YUN ZHU 1,006 Super User 2025 Season 1

#3
Mansi Soni Profile Picture

Mansi Soni 872

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans