To enable and disable a field based on value in other field :
class PurchTableFormExtension
{
[FormDataSourceEventHandler(formDataSourceStr(PurchTable, PurchLine), FormDataSourceEventType::Activated)]
public static void PurchLine_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
{
FormRun formRun = sender.formRun();
FormDataSource PurchTable_ds = formRun.dataSource(formDataSourceStr(PurchTable, PurchTable)) as FormDataSource;
PurchTable purchTable= PurchTable_ds.cursor();
FormStringControl NCMRNo = formRun.design(0).controlName("NCMR_OINCMRNum_011");
FormStringControl NCMRDispositionCode = formRun.design(0).controlName("NCMR_OINCMRDispositionCodeId_011");
if(NCMRNo.text() != "")
NCMRDispositionCode.enabled(true);
else
{
NCMRDispositionCode.text(" ");
NCMRDispositionCode.enabled(false);
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormControlEventHandler(formControlStr(PurchTable, NCMR_OINCMRNum_011), FormControlEventType::Modified)]
public static void NCMR_OINCMRNum_011_OnModified(FormControl sender, FormControlEventArgs e)
{
FormRun formRun = sender.formRun();
FormDataSource PurchTable_ds = formRun.dataSource(formDataSourceStr(PurchTable, PurchTable)) as FormDataSource;
PurchTable purchTable= PurchTable_ds.cursor();
FormDataSource PurchLine_ds = formRun.dataSource(formDataSourceStr(PurchTable, PurchLine)) as FormDataSource;
PurchLine purchline= PurchLine_ds.cursor();
FormStringControl NCMRNo = formRun.design(0).controlName("NCMR_OINCMRNum_011");
FormStringControl NCMRDispositionCode = formRun.design(0).controlName("NCMR_OINCMRDispositionCodeId_011");
if(NCMRNo.text() != "")
NCMRDispositionCode.enabled(true);
else
{
purchline.OINCMRDispositionCodeId_011 = "";
NCMRDispositionCode.enabled(false);
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormControlEventHandler(formControlStr(PurchTable, NCMR_OINCMRNum_011), FormControlEventType::LostFocus)]
public static void NCMR_OINCMRNum_011_OnLostFocus(FormControl sender, FormControlEventArgs e)
{
FormRun formRun = sender.formRun();
FormDataSource PurchTable_ds = formRun.dataSource(formDataSourceStr(PurchTable, PurchTable)) as FormDataSource;
PurchTable purchTable= PurchTable_ds.cursor();
FormStringControl NCMRNo = formRun.design(0).controlName("NCMR_OINCMRNum_011");
FormStringControl NCMRDispositionCode = formRun.design(0).controlName("NCMR_OINCMRDispositionCodeId_011");
if(NCMRNo.text() != "")
NCMRDispositionCode.enabled(true);
else
{
NCMRDispositionCode.text(" ");
NCMRDispositionCode.enabled(false);
}
}
===============================================================
//Enable and Disable field "Extra Calculationday" based on Enum value for the field "CreditCheckType".
[FormControlEventHandler(formControlStr(CustParameters, FormGroupControl1_FINCustCreditCheckType), FormControlEventType::Modified)]
public static void FormGroupControl1_FINCustCreditCheckType_OnModified(FormControl sender, FormControlEventArgs e)
{
FormRun formRun = sender.formRun();
FormComboBoxControl finCreditCheckType = formRun.design(0).controlName("FormGroupControl1_FINCustCreditCheckType");
FormIntControl extraCalculationDays = formRun.design(0).controlName("FormGroupControl1_EQNExtraCalculationDays");
if(finCreditCheckType.valueStr() == enum2str(FINCustCreditCheckType::BasedonExposure))
{
extraCalculationDays.enabled(true);
}
else
{
extraCalculationDays.enabled(false);
}
}
==============================================================
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormControlEventHandler(formControlStr(PurchTable, NCMR_OINCMRDispositionCodeId_011), FormControlEventType::Lookup)]
public static void NCMR_OINCMRDispositionCodeId_011_OnLookup(FormControl sender, FormControlEventArgs e)
{
FormRun formRun = sender.formRun();
FormStringControl NCMRDispositionCode = formRun.design(0).controlName("NCMR_OINCMRDispositionCodeId_011");
Query query = new Query();
QueryBuildDataSource qbds;
SysTableLookup sysTableLookup;
sysTableLookup = SysTableLookup::newParameters(tableNum(OINCMRDispositionCode), sender);
sysTableLookup.addLookupfield(fieldNum(OINCMRDispositionCode,NCMRDispositionCodeId));
sysTableLookup.addLookupfield(fieldNum(OINCMRDispositionCode, Description));
qbds = query.addDataSource(tableNum(OINCMRDispositionCode));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
}
No comments:
Post a Comment