修改方法

时间:2019-04-11 11:31:45

标签: axapta x++ dynamics-365

我需要编写一个Modify方法。

有一个字段: LineViewHeader_AccountType ;串;可能的值:内部,客户,租户

根据选择的值,必须在以下字段中列出值: LineViewHeader_AccountNum

当前,无论在AccountType中选择了什么,它都会列出AccountNum中的所有值。

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

        ret = super();

        return ret;
    }
}

2 个答案:

答案 0 :(得分:4)

您需要将LineViewHeader_AccountType控件值设置为范围:

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

答案 1 :(得分:0)

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