Making certain fields non editable thru coding

Hi all,

Please help about how to make certain fields are not editable field in Sales Order form (form 42)? What I am trying to do is changing certain fields in sales order sub form (form 46) to be non editable if one Boolean field in the Sales Header is checked.

Thank you,


You can only do this with code, sorry.

David - that’s the answer I want to know; what and how to code it. [:)]

Thanks - ZEN

In the sub form, you need code that

Get Sales header
check if fields are to be not editable.
set fields as editable or not (Currform.MyField.EDITABLE(FALSE);

call the function when the sub form opens, and when the saels header changes.

There is one problem with that. You can change the property just for whole column, not for particular field on particular line. For me it is better to use OnValidate trigger to show error when user tries to change value in this “protected” field.

I think since its based on a field in the header, that he means the whole column.

Actually Kine is right. Even if you want the fields not editable to make it easier for the users to enter data. You must also add triggers ont he individual fields to make sure that some how the user does not get around this. Though it does depend on your business applicaiton.

Hi Kine,

I tried your input and it works perfectly but the User’s request is to make the fields not editable. I also tried David’s suggestion but still struggling with the some error. One error is come over the other [:)].


Hi! David - it’s not the whole column but few fields only.



It would help then if you could explain what you want.

Field = Column

Record = Row,

do you just want to make the fields editable for onluy some records ?

If so don’t it will be a mess. Just use the code as suggested by Kamil.

To set the properties of a subform field based upon the header form you need to make some considerations otherwise it might be quirky.

  1. The boolean field you add to the sales header probably should be set programically rather than allowing the user to toggle the value, otherwise you will need to add additional code to the fields on validate trigger to check any existing fields in the line records meet the requirements of the new value of the field.

  2. This is a change only to the form and therefore other forms that may use these same tables will have to be modified if you want the same requirements.

Add the boolean field to table 42, for the purposes of this example i am calling the Field “Set Fields”.

Next in the subform 46 you need to go to each textbox that you want to chang, and in the properties change the name property (i.e. change to LocationCode);

Create a global function in the subform (i.e "Activate Fields)

In the “Activate Fields” Function enter the following code:
SalesHeader.GET(“Document Type”,“Document No.”);
CurrForm.LocationCode.EDITABLE(NOT SalesHeader.“Set Fields”);
CurrForm.TaxAreaCode.EDITABLE(NOT SalesHeader.“Set Fields”);

Do this for each field you want to include. Note: I assume true value for “Set Fields” means not editable and false means editable. If your value is reveresed then enter CurrForm.LocationCode.EDITABLE(SalesHeader.“Set Fields”);

Add code to the following subform triggers:
Form - OnAfterGetCurrRecord()
CurrForm.ItemPanel.VISIBLE := Type = Type::Item;
ActivateFields; <<<<<<<<<

Form - OnNewRecord(BelowxRec : Boolean)
Type := xRec.Type;

If you are allowing the user to change the value of “Set Fields” then you will need to add code to the fields on-validate trigger to test that any existing lines do not violate the new field value. Of course if you are allowing the user to change the “Set Fields” you will need to add it to form 42.

John, you’re GREAT!! [Y] Thank you so very much!!!