Quantcast
Channel: Dynamics 365 Business Central/NAV User Group
Viewing all articles
Browse latest Browse all 11285

Forum Post: RE: Create a Freight Calculator Page in AL - Dynamics 365 Business Central

$
0
0
If you used table fields for controls, TableRelation property could help you filter the dropdown list - it can be extended to apply a filter from another field of the same table. But since it's all variables, TableRelation will not work, it's not so flexible to pick filter values from variables. In this case, you'll have to write code for the OnLookup trigger of the control. For example, this is how it would work for standard tables "Country/Region" and "Post Code". Btw, take a look at these tables - probably they can help you normalize the data structure. page 50102 "Address Sample" { PageType = Card; layout { area(content) { group(AddressGroup) { field(CountryCodeControl;CountryCode) { Caption = 'Country'; TableRelation = "Country/Region"; } field(CityControl;City) { Caption = 'City'; trigger OnLookup(var Text : Text) : Boolean; var PostCode: Record "Post Code"; PostCodesList: Page "Post Codes"; LookupConfirmed: Boolean; begin if CountryCode = '' then exit(false); PostCode.FilterGroup(2); PostCode.SetRange("Country/Region Code",CountryCode); PostCode.FilterGroup(0); PostCodesList.LookupMode(true); PostCodesList.SetTableView(PostCode); LookupConfirmed := PostCodesList.RunModal() = "Action"::LookupOK; if LookupConfirmed then begin PostCodesList.GetRecord(PostCode); Text := PostCode.City; end; exit(LookupConfirmed); end; } } } } var CountryCode: Code[10]; City: Text[30]; } Regarding filtergroups and functions like LookupMode and SetTableView, you can read related MSDN articles on older versions on NAV - functions are the same. There is no way to write SQL queries in AL. There is a substitute for SQL called query object: https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-query-object But in most cases there is no benifit in query compared to AL code. It is only recommended if you need to join large tables where performance is critical.

Viewing all articles
Browse latest Browse all 11285

Trending Articles