How to get the form object in a ListPageInteraction class?

14,490

Solution 1

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

Solution 2

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.
Share:
14,490
maqk
Author by

maqk

Hello, greetings from Maqk [Muhammad Abdul Qadir Khan]. The way my name is put like that is for your own ease . This short encapsulation also saves me from just being called Qadir :D Software Engineering is my bread and butter. I have a total of 4 years of experience in software development. From last two years, I am surfing over the ERP Sea using the Dynamics AX boat :D. Put simply, I have been a technical consultant for Dynamics AX platform in all this duration. My current focus is ERP development, specifically Dynamics AX 2012 as the product to learn technically while ERP as general to learn from functional perspective. One of the reason to have this blog is to facilitate this learning experience. I am also looking for an MBA from abroad (US / UK) in the next 2 - 3 years إن شاء الله‎ which will enhance me further for a Techno-Managerial post. For a great success in my MBA, I am keen to develop ERP functional knowledge including all the basic horizontals (Financials, SCM, Production). From then on, I can see my self much more successful in the ERP consultancy domain As a person what describes me more realistically is my twitter tag line: Flashing LEDs, birds &amp; beasts, Shahid Afridi's brand of cricket, Ferrari RED, madZizouFan, and an honest strive to find out the REAL BIG TRUTH Over the years, I have discovered blogging a great way to Bookmark your own learnings for future reference Share it with the people around the globe Add into the knowledge sharing stream And finally a great way to stand out of the box too :D To benefit the whole world from the above four points, I am keen to keep my blog ever green. Thanks for visiting my blog. For any queries, drop an email to Maqk® Email

Updated on June 14, 2022

Comments

  • maqk
    maqk almost 2 years

    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?

  • Kempeth
    Kempeth over 5 years
    This is also a live saver if you're trying to get access to a button from a method on a Form DataSource!