General X++ Development

How do I make a form field editable based on a condition?

Asked by Sunny Vasty· Aug 13, 2026· 1 answers

How do I make a form field editable based on a condition?

SSunny Vasty75 reputation · answered Aug 13, 2026

For a datasource-bound field, use allowEdit() on the datasource field.

X++
boolean canEdit = salesTable.SalesStatus == SalesStatus::Backorder;

SalesTable_ds
    .object(fieldNum(SalesTable, YourField))
    .allowEdit(canEdit);

I prefer this over only enabling/disabling a single control because it applies to the bound field regardless of which control is displaying it.