D365 Business CentralMake the editable fields un-editable based on a condition in NAV
This article explains how to change the editable fields into un-editable fields based on certain condition. In this article, we make the page fields un-editable on change of status from Open to Released. For example, the fields like No., Description etc. will be freeze when the NAV page status changes to Released.
Microsoft Dynamics NAV 2017.
- We create a Boolean field in the Global variable (Ctrl + G) in the NAV page and sets the property by clicking on (Shift + F4) of the boolean variable ‘IncludeInDataset’ to yes. This property is set to yes when the variable is used as the value of the Editable property, enabled property, visible property or StyleExpr property.
- Now we select the fields of the NAV which needs to be changed to un-editable and set the enabled properties of the field to the Boolean field name.
- Now in the C/AL code (F9), in the ‘OnAfterGetCurrRecord’ we place a condition that if the status is Released then the Boolean field ‘fieldeditable’ is set to false this will freeze the fields and only if the status is open the ‘fieldeditable’ will be set to true. By default the value of the boolean variable is true.
Below is the screenshot of the NAV page with status open.
Below in the screenshot , the approval status is ‘released’.