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?
Hello ,
Did you manage to solve this? Appreciate your help :)
Thanks,
Mishal
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
You just need to create a codeunit and subscribe to that event you don’t need tableextension
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;
}
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.
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
Sohail Ahmed
1,234
YUN ZHU
1,006
Super User 2025 Season 1
Mansi Soni
872