1
votes

I need to write a modify method.

There is field : LineViewHeader_AccountType; string; with possible values: Internal, Customer, Tenant

Depending on which value is selected, it is necessary to list the values ​​in the field: LineViewHeader_AccountNum

Currently it lists all values in AccountNum, no matter what is selected into in AccountType.

[Control("ComboBox")]
class LineViewHeader_AccountType
{
    /// <summary>
    ///
    /// </summary>
    /// <returns></returns>
    public boolean modified()
    {
        boolean ret;

        ret = super();

        return ret;
    }
}
2
If I understand you correctly you need to filter lookup for AccountNum based on the value of AccountType. Please check the following link thinkinginax.blogspot.com/2018/04/… - Aliaksandr Maksimau

2 Answers

4
votes

You need to set LineViewHeader_AccountType control value as range:

[FormControlEventHandler(formControlStr(PMCContractDetails, 
LineViewHeader_AccountNum), FormControlEventType::Lookup)]
public static void LineViewHeader_AccountNum_OnLookup(FormControl sender, 
FormControlEventArgs e)
{
    Query                   query = new Query();
    QueryBuildDataSource    queryBuildDataSource;
    SysTableLookup          sysTableLookup;
    FormRun                 formRun;
    FormControl             formCtrl;


    formRun = sender.formRun();
    formCtrl = formRun.design().controlName(formControlStr(PMCContractDetails, LineViewHeader_AccountType));

    sysTableLookup = SysTableLookup::newParameters(tableNum(PMCContract), sender);
    queryBuildDataSource = query.addDataSource(tableNum(PMCContract));
    queryBuildDataSource.addRange(fieldNum(PMCContract, AccountType)).value(queryValue(formCtrl.valueStr()));

    sysTableLookup.addLookupField(fieldNum(PMCContract, AccountType), true);
    sysTableLookup.addLookupMethod(tableMethodStr(PMCContract, AccountNum));

    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();       
}
0
votes
[FormControlEventHandler(formControlStr(PMCContractDetails, LineViewHeader_AccountNum), FormControlEventType::Lookup)]
public static void LineViewHeader_AccountNum_OnLookup(FormControl sender, FormControlEventArgs e)
{
    Query                   query = new Query();
    QueryBuildDataSource    queryBuildDataSource;
    SysTableLookup          sysTableLookup;

    sysTableLookup = SysTableLookup::newParameters(tableNum(PMCContract), sender);
    queryBuildDataSource = query.addDataSource(tableNum(PMCContract));

    sysTableLookup.addLookupField(fieldNum(PMCContract, AccountType), true);
    sysTableLookup.addLookupMethod(tableMethodStr(PMCContract, AccountNum));

    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();       
}