This article depicts an example and notes of how to set up an AL query in a BC extension in order to read from and write to custom tables and fields with an API call.
How to:
- The casing of the various values is intentional. BC is finicky about casing in some instances and SIQ uses these conventions. Entity Name and EntitySetName need to be ALL lowercase
- The APIGroup, APIPublisher and APIVersion must match the example exactly. This will allow StockIQ to build the correct URL.
- ODataKeyFields needs to be SystemId
- Note the EntitySetName is the plural of the EntityName. We recommend putting an "siq" in front of your chosen name to prevent duplicate page names.
- Source Table is the custom table we are reading from/writing to
- Please include fields to uniquely identify records. For example, a purchase order may have DocumentNo and LineNo. An item record may have ItemNo.
- You must include SystemId as a field if StockIQ is writing back to your source table/field within the source table.
///Test Page API
page77701 SiqPurchaseLineTest
{
PageType = API;
Caption ='Purchase Line Test API';
APIPublisher ='StockIQ';
APIGroup ='SIQ';
APIVersion ='v1.0';
EntityName ='purchaselinetest';
EntitySetName ='purchaselinetests';
SourceTable = "Purchase Line";
DelayedInsert = true;
ODataKeyFields = SystemId;
layout
{
area(Content)
{
repeater(GroupName)
{
field(SystemId; Rec."SystemId"){ }
field(DocumentType; Rec."Document Type"){ }
field(DocumentNo; Rec."Document No."){ }
field(LineNo; Rec."Line No."){ }
field(YourCustomColumnA; "Your Custom Column A"){ }
}
}
}
}