开发者

How to get the form object in a ListPageInteraction class?

开发者 https://www.devze.com 2023-03-24 23:31 出处:网络
Working on Microsoft Dynamics AX 2012. I have a listpage form which has a referenced ListPageInteraction class, just wanted to change the label / caption of a few control. For this I need to do somet

Working on Microsoft Dynamics AX 2012.

I have a listpage form which has a referenced ListPageInteraction class, just wanted to change the label / caption of a few control. For this I need to do something like:

element.form().design().control(开发者_如何学运维'<YourControlName>');

but I cant get this method on the ListPageInteraction class. I have decided to work on the class's initialized method. However there is no way to get to the form from there, how can I get to the controls and set labels?


common = this.listPage().activeRecord('Table');
if(common.isFormDataSource())
{
    fds = common.dataSource();
    fds.formRun().control(fds.formRun().controlId('ControlOfScreen')).
       userPromptText('New Description');
}

Another example from projProjectTransListPageInteraction.initializeQuery() perspective changing the label of TransDate field from grid on form projProjectTransactionsListPage

public void initializeQuery(Query _query)
{
    QueryBuildRange     transDateRange;
    // ListPageLabelChange =>
    Common              externalRecord;
    FormDataSource      frmDs;
    FormRun             formRun;
    FormControl         frmCtrl;
    // ListPageLabelChange <=
    ;

    queryBuildDataSource = _query.dataSourceTable(tableNum(ProjPostTransView));
    transDateRange = SysQuery::findOrCreateRange(queryBuildDataSource, fieldNum(ProjPostTransView, TransDate));

    // Date range is [(today's date - 30)..today's date] if not showing transactions for a particular project.
    // Date range is [(dateNull())..today's date] if showing transactions for a particular project so that all transactions are visible.
    transDateRange.value(SysQuery::range(transStartDate, systemDateGet()));

    this.linkActive(_query);

    // ListPageLabelChange =>
    externalRecord = this.listPage().activeRecord(_query.dataSourceTable(tableNum(ProjPostTransView)).name());//No intrisic function for form DS?
    if(externalRecord.isFormDataSource())
    {
        frmDs   = externalRecord.dataSource();
        formRun = frmDs.formRun();
        if(formRun)
        {
            frmCtrl = formRun.design().controlName(formControlStr(projProjectTransactionsListPage,TransDate));
            if(frmCtrl)
            {
                frmCtrl.userPromptText("newName");
            }
        }
    }
    // ListPageLabelChange <=
}


I don't think it is possible to get the FormRun object from ListPageInteraction. If you were able to do it the rest would be easy:

FormControl fc = formRun.design().controlName(formcontrolstr(formName, controlName));
// etc.
0

精彩评论

暂无评论...
验证码 换一张
取 消