Make table fields not editable with condition

Hallo everyone,

i would like to make some fields in a table ForecastSales editable depending on other fields in this table.

allowEdit = ForecastSales.FOMBudgetLineArchivedCommitted == 0 || ForecastSales.FOMBudgetLineArchivedConsumed == 0;

allowEdit = allowEdit && !ForecastSales.RecId && ( ProjTable::find( ForecastSales.ProjId ).FOMProjForecastMode == FOMProjForecastMode::Manual && selectionModelTypeFilter != enum2str(FOMForecastModelType::Budget) );

ForecastSales_ds.object( fieldnum( ForecastSales, StartDate )).allowEdit( allowEdit );

But I am having trouble with the condition for the “allowEdit”-Variable.

My conditions for the editing the fields are:

  1. the field Committed Budget is 0 OR the field ConsumedBudget is 0.

  2. the ModelType of the Plan is “Budget” - that part should be right.

As a result of this code non of the fields in the table are editable [:S]

Can anybody help me with that please?

1 Like

In which method are you using that code? Are you using it in a table or a form?

You need to write these conditions in a form method, which uses this table as a datasource. Override the method active() of the datasource and write it there.

Thank you, I write the code in the form - the location has been proved as correct. :slight_smile:

And is it in the active() method of the datasource?

If it is, then debug and see if AllowEdit variable has the value which you expect…

Thank you for your help!

My condition was built incorrectly - I should have set another fields in the “ForecastSales.BudgetLineArchivedCommitted == 0”