DarthCSharper
DarthCSharper

Reputation: 133

Modified Method

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;
    }
}

Upvotes: 1

Views: 570

Answers (2)

Aliaksandr Maksimau
Aliaksandr Maksimau

Reputation: 2281

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();       
}

Upvotes: 4

DarthCSharper
DarthCSharper

Reputation: 133

[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();       
}

Upvotes: 0

Related Questions