Form Level Fields are ENABLE/Disable based on the other field

Dear Frnds

I have one requirement , i am doing the new form in that overview, General & Accrual three tab pages are three

In overview grid Accrual field (yes/no combo box type), if i select “yes” then only accrual Tab fields are Enable otherwise Disable

in data source , Accrual field i wrote a modified method like as follows below

public void modified()

{

super();

if (CEMPAbsence.Accrual == Accrual::Yes )

{

CEMPAbsence_ds.object(fieldNum(CEMPAbsence,AccrualType)).enabled(True);

CEMPAbsence_ds.object(fieldNum(CEMPAbsence,Numberofunits)).enabled(True);

CEMPAbsence_ds.object(fieldNum(CEMPAbsence,Rule)).enabled(True);

CEMPAbsence_ds.object(fieldNum(CEMPAbsence,Accrueperiod)).enabled(True);

CEMPAbsence_ds.object(fieldNum(CEMPAbsence,FromDate)).enabled(True);

CEMPAbsence_ds.object(fieldNum(CEMPAbsence,Accrueperiodunit)).enabled(True);

//element.SetAccrual();

}

else

{

CEMPAbsence_ds.object(fieldNum(CEMPAbsence,AccrualType)).enabled(false);

CEMPAbsence_ds.object(fieldNum(CEMPAbsence,Numberofunits)).enabled(false);

CEMPAbsence_ds.object(fieldNum(CEMPAbsence,Rule)).enabled(false);

CEMPAbsence_ds.object(fieldNum(CEMPAbsence,Accrueperiod)).enabled(false);

CEMPAbsence_ds.object(fieldNum(CEMPAbsence,FromDate)).enabled(false);

CEMPAbsence_ds.object(fieldNum(CEMPAbsence,Accrueperiodunit)).enabled(false);

}

CEMPAbsence_ds.reread();

CEMPAbsence_ds.refresh();

}

but one problem is there when i reopen the form

this one is not working

can u plz give the suggestion any body

Try adding the same code in the active method of the datasource table.

Dear Frnds,

I’m newbie with x++ and i’m trying to enable/disable a field with a checkbox, so this is the code in the “modified” methode of the checkbox datasource :

public void modified()

{

;

super();

projTable.editSubProj(fieldnum(ProjTable, SoumisARemise),projTable.SoumisARemise,projTable.orig().SoumisARemise);

// the code above works perfectly

if (this.getValue() == true)

{

// here is the problem ! the compilor tells me that there are a syntax error

ProjTable.MontantRemisePrevue.enabled(true);

}

else

{

ProjTable.MontantRemisePrevue.enabled(false) ;

}

}

Thx.

Hi mourad.

  1. Probably you need call your checkbox name (MontantRemisePrevue instead of ProjTable.MontantRemisePrevue)

  2. Also check name of your combox (is it exactly MontantRemisePrevue?) and check Autodeclare property field of form element. If it sets to false, you can use this element in code. Put this property to “Yes”.

hi,

here is the sample code

public void modified()
{
super();
if(SampleTest.IsActive == noyes::Yes) //this is my boolean field
{
SampleTest_ds.object(fieldnum(SampleTest,EmplId)).allowEdit(true); //my field 1
SampleTest_ds.object(fieldnum(SampleTest,Name)).allowEdit(true); // my field 2
}
else
{
SampleTest_ds.object(fieldnum(SampleTest,EmplId)).allowEdit(false);
SampleTest_ds.object(fieldnum(SampleTest,Name)).allowEdit(false);
}
}

you can even simplify,

SampleTest_ds.object(fieldnum(SampleTest,EmplId)).allowEdit(SampleTest.IsActive == noyes::Yes); //my field 1
SampleTest_ds.object(fieldnum(SampleTest,Name)).allowEdit(SampleTest.IsActive == noyes::Yes); // my field 2