› Dynamics NAV › Displaying Lookup Form on a field based on a particular selected option of another field in Request page of a Report in Microsoft Dynamics NAV

Displaying Lookup Form on a field based on a particular selected option of another field in Request page of a Report in Microsoft Dynamics NAV

 Tina Menezes   Leave a comment

Introduction:

In Microsoft Dynamics NAV, Lookup Form on a field corresponding to a particular selected option of another field can be displayed in the Request page of a report using C/AL code. In this article we are going to see the procedure with the code required to achieve the same.

Pre-requisites:

Microsoft Dynamics NAV 2017

Procedure:

Step 1:

Consider the below two fields which are created in the request page of a report i.e. ‘Bal. Account Type’ and ‘Bal. Account No’.

Step 2:

BalAccountType is a global C/AL variable of type option which has two options in OptionString property i.e. G/L Account and Bank Account.

Condition:

If G/L Account option is selected in the ‘Bal. Account Type’ field, then G/L Account List i.e. Page 18 should be displayed as a lookup form in the ‘Bal. Account No’ field.

If Bank Account option is selected in the ‘Bal. Account Type’ field, then Bank Account List i.e. Page 371 should be displayed as a lookup form in the ‘Bal. Account No’ field.

Step 3:

Firstly in ‘SelectionFilterManagement’ i.e. Codeunit 46, create a function GetSelectionFilterForBankAccount().

In the above C/AL code, BankAccount is a global C/AL variable of type record ‘Bank Account’ i.e. Record 270.

The local parameter of the function is:

Return value of the function is:

The variable of the function is:

Step 4:
Now, create a function ‘GetSelectionFilter()’ in ‘Bank Account List’ page.

In the above C/AL code, BankAccountTable is a global C/AL variable of type record ‘Bank Account’ i.e. Record 270.

The properties of the above function are as follows:

The return value of the function is:

Step 5:

Create a function ‘GetSelectionFilter’ in ‘G/L Account List’ i.e. Page 18

In the above code, ‘GLAcc’ is a global C/AL variable of type record i.e. Record 15.

The return value of the function is:

The variables of the function are:

Step 6:

To display the lookup form based on the condition mentioned in step 2, C/AL code needs to be added in the OnLookup trigger of ‘Bal. Account No’ field.

In the above code, ‘BankAccountNoList’ is a global C/AL variable of type Page ‘Bank Account List’ i.e. Page 371 and GLAccountPage is a global C/AL variable of type Page ‘G/L Account List’ i.e. Page 18.

Following screenshots show the lookup form being displayed based on a option selected in another field:

If G/L Account is selected in Bal. Account Type, the following lookup form i.e. ‘G/L Account List’ is displayed.

If ‘Bank Account’ is selected in Bal. Account Type, the following lookup form i.e. ‘Bank Account List’ is displayed.

Thus after completing the above mentioned steps, Lookup Form on a field corresponding to a particular condition of another field can be displayed in the Request page of the report.

 


Liked it? Share it.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.