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

I have the same question (0)
  • Suggested answer
    JAngle Profile Picture
    133 on at

    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

  • Suggested answer
    Suresh Kulla Profile Picture
    50,243 Super User 2025 Season 2 on at

    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.

  • Community Member Profile Picture
    on at

    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;

    }

  • Verified answer
    Suresh Kulla Profile Picture
    50,243 Super User 2025 Season 2 on at

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

  • Community Member Profile Picture
    on at

    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

  • mishaln Profile Picture
    15 on at

    Hello  ,

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

    Thanks,

    Mishal

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 2,606

#2
YUN ZHU Profile Picture

YUN ZHU 931 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 773 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans