web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

ReferenceGroup

(0) ShareShare
ReportReport
Posted on by 6,648

Hi ALL,

I have a Reference Group in my grid and I want to set one of the row of this Reference Group as default value in AOT.

Who can help me?

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    239,108 Most Valuable Professional on at

    What do you mean by "in AOT"? In code at runtime? If so, simply assign the right value to the backing field.

  • Hossein.K Profile Picture
    6,648 on at

    Hi Martin,

    Yes, in code

  • Verified answer
    Hossein.K Profile Picture
    6,648 on at

    Hi ALL,

    I override this lookupReference method in my ReferenceGroup. 

    public Common lookupReference()
    {
    //FormReferenceControl _formReferenceControl;
    SysReferenceTableLookup sysTableLookup = SysReferenceTableLookup::newParameters(tableNum(myTable), this);

    Query testQuery;
    QueryBuildDataSource qbds;

    QueryBuildRange qbr;

    Common selectedRecord;

    str test;

    // Display the coulmns fields in the lookup form.
    testQuery= new Query();
    //test = strFmt('(%1 == Final)',fieldStr(myTable, ProductTypeID));

    //sysTableLookup.addLookupfield(fieldNum(myTable, RecId));
    // sysTableLookup.addLookupfield(fieldNum(myTable, ProductTypeName));
    sysTableLookup.addLookupfield(fieldNum(myTable, ProductTypeID));

    // Create a custom Query
    qbds = testQuery.addDataSource(tableNum(myTable));

    qbds.addRange(fieldnum(myTable, ProductTypeID)).value('Final');

    sysTableLookup.parmQuery(testQuery);

    selectedRecord = sysTableLookup.performFormLookup();

    return sysTableLookup.performFormLookup();


    //return sysTableLookup.performFormLookup();
    }

  • Martin Dráb Profile Picture
    239,108 Most Valuable Professional on at

    Aha, so you actually wanted a lookup and not a default value...

  • Hossein.K Profile Picture
    6,648 on at

    Hi Martin,

    I wanted both of them.You know,how I can set default value with code?

    thanks

  • Martin Dráb Profile Picture
    239,108 Most Valuable Professional on at

    That's what I answered in my first reply. Simply assign a value to the field, e.g. myTable.MyReferenceField = 123456789. (The number is a foreign key, i.e. RecId of the referenced record.)

    I didn't do anything more in this thread because I felt that your only question had been answered. You didn't mention any lookup and you didn't say that you didn't understand how to set the default value.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Basit Profile Picture

Basit 1

#1
GL-01081504-0 Profile Picture

GL-01081504-0 1

#1
Roya Profile Picture

Roya 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans