I want to create Assembly header via BC364 API, so i wrote this AL extension:
page 50132 CustomAssemblyHeader
{
PageType = API;
APIVersion = 'v2.0';
APIPublisher = 'streamline';
APIGroup = 'export';
EntityName = 'assemblyHeader';
EntitySetName = 'assemblyHeaders';
ODataKeyFields = SystemId;
SourceTable = /Assembly Header/;
DelayedInsert = true;
layout
{
area(Content)
{
repeater(Group)
{
field(id; Rec.SystemId)
{
Caption = 'id';
}
field(documentType; Rec./Document Type/)
{
Caption = 'documentType';
}
field(item; Rec./Item No./)
{
Caption = 'item';
}
field(qty; Rec.Quantity)
{
Caption = 'qty';
}
field(location; Rec./Location Code/)
{
Caption = 'qty';
}
}
}
}
}
app.json
{
/id/: /d0e31363-2e61-4e64-jsbf-fe2bb22e84354/,
/name/: /name/,
/publisher/: //,
/version/: /2.0.0.3/,
/brief/: //,
/description/: //,
/privacyStatement/: //,
/EULA/: //,
/help/: //,
/url/: //,
/logo/: //,
/dependencies/: [],
/screenshots/: [],
/platform/: /1.0.0.0/,
/application/: /17.0.0.0/,
/idRanges/: [
{
/from/: 50090,
/to/: 50149
}
],
/contextSensitiveHelpUrl/: https://Extention2020wave2.com/help//,
/showMyCode/: true,
/runtime/: /7.0/
}
To create a new record i perform this request via Postman:
POST https:/api.businesscentral.dynamics.com/v2.0/tenantId/Sandbox2/api/streamline/export/v2.0/companies(0dd10330-db46-ee11-be72-6045bdac9e37)/assemblyHeaders
Body:
{
/documentType/: /1/,
/item/: /1969-W/,
/qty/: 2,
/location/: /GREEN/
}
Response:
{
/error/: {
/code/: /Application_DialogException/,
/message/: /Due Date is before Ending Date 02/13/24. CorrelationId: a26bd40a-97a2-48f1-ad6e-095267a90331./
}
}
Than i add dates into my page:
page 50132 CustomAssemblyHeader
{
PageType = API;
APIVersion = 'v2.0';
APIPublisher = 'streamline';
APIGroup = 'export';
EntityName = 'assemblyHeader';
EntitySetName = 'assemblyHeaders';
ODataKeyFields = SystemId;
SourceTable = /Assembly Header/;
DelayedInsert = true;
layout
{
area(Content)
{
repeater(Group)
{
field(id; Rec.SystemId)
{
Caption = 'id';
}
field(documentType; Rec./Document Type/)
{
Caption = 'documentType';
}
field(item; Rec./Item No./)
{
Caption = 'item';
}
field(qty; Rec.Quantity)
{
Caption = 'qty';
}
field(location; Rec./Location Code/)
{
Caption = 'qty';
}
field(dueDate; Rec./Due Date/)
{
Caption = 'dueDate';
}
field(endDate; Rec./Ending Date/)
{
Caption = 'endDate';
}
}
}
}
}
And change request body:
{
/documentType/: /1/,
/item/: /1969-W/,
/qty/: 2,
/location/: /GREEN/,
/dueDate/: /2024-02-14/,
/endDate/: /2024-02-13/
}
But i still have the same error:
{
/error/: {
/code/: /Application_DialogException/,
/message/: /Due Date is before Ending Date 02/13/24. CorrelationId: a26bd40a-97a2-48f1-ad6e-095267a90331./
}
}
I think that error is because Due Date is empty and less than Ending Date which somehow is equal to 2024-02-13.
I also found out in source code that error occurred in OnValidate() trigger in /Due date/ field of /Assembly Header/ table:
field(24; /Due Date/; Date)
{
Caption = 'Due Date';
trigger OnValidate()
begin
ValidateDueDate(/Due Date/, true);
end;
}
And inside ValidateDueDate and ValidateDates funstions i found this dates checks:
if /Due Date/ < /Ending Date/ then
Error(Text015, FieldCaption(/Due Date/), /Due Date/, FieldCaption(/Ending Date/), /Ending Date/);
if /Ending Date/ < /Starting Date/ then
Error(Text015, FieldCaption(/Ending Date/), /Ending Date/, FieldCaption(/Starting Date/), /Starting Date/);
How can i solve this problem?