How do I make a specific field in a grid mandatory?

I want to say, If column1 = “yes”, then column2 is mandatory. I’d like to do this through code, as column 1 can change. Can this be done?

Column1 Column2
Yes Mandatory
No abc
Yes def Mandatory
Yes Mandatory
No

Hi Alex,

In the Form, make column2 AutoDeclaration to Yes.
In the init() method of the form place this code Table_column2.mandatory(false).
In the form datasource – fields – column2(field) – override the modified() method

public void modified()
{
super();
if(table.Column1 == NoYesCombo::Yes)
{
Table_column2.mandatory(true); //Table_column2 – name of the column2 in the form grid level…
}
else
{
Table_column2.mandatory(false);
}
}

Naresh kolli

Thanks for the reply. This makes the entire Column2 mandatory based on Column1 unfortunately. I would like to make only specific fields mandatory.

The other option would be overriding the validateWrite() method…