Hey all,
I am completely new at AL programming and am doing a little testing in my business central sandbox.
On my report's request page I would like to add a field in which I can choose a customer and then only show data for the chosen customer in the report.
I have successfully added the field but fail to properly configure the DataItemTableView, so the data passed to the report layout is pre-filtered.
This is the field I added ("ChosenCust_Code" is the variable I want to store my user-chosen value in):
field(ChosenCust; ChosenCust_Code)
{
Caption = 'Customer to notify:';
ToolTip = 'Specifies the customer to create the overdue notice for.';
ApplicationArea = All;
TableRelation = Customer."No.";
}
In my data item, I tried to use the following line to filter the data based on the user-chosen value:
DataItemTableView = where("No." = const(ChosenCust_Code));
"No." is the field in my data item table (PK) which should align with the ChosenCust_Code variable.
I have searched the web for half an hour now and figured I might be faster just asking here.
Answers
No need for a complicated variable trick.
RIS Plus, LLC
RIS Plus, LLC
https://www.youtube.com/embed/videoseries?list=PL1FESh9FqyhQxkZXYYp1X1tTpXf3-9iSR
RIS Plus, LLC
I just tried getting into variables and thus wanted to try this example.
Also if I was a user it would save me two clicks and some scrolling or searching.
So is there any way to properly pass user input to a query ("query" not meant in AL-syntax)?
The DataItemTableView is for the customer-table, so "No." is the field name. Or what did you mean by the foreign key "customer no."?
The way you explained it, I thought you had a table with a link to the customer number, so that's why I suggested the name.
You can create a field on the request page and set a variable as the source. Each control has triggers for OnValidate and OnLookup. You can program those to display the customer list and catch the record that the user selects. Then you can use the variable as the filter value in the dataitem trigger.
RIS Plus, LLC
I created a trigger OnPreDataItem() in my Customer DataItem and inside the trigger I wrote