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 :
Finance | Project Operations, Human Resources, ...
Unanswered

Filtering Lookup for String x++

(0) ShareShare
ReportReport
Posted on by 65

I had lookup fields (type:int64, Extended from RefRecId) and I had written lookup filtering code for them but I had to convert them into strings ( I had added relations to make them lookup fields) But since they are "String" instead of "reference group" my code doesn't work. How can I filter them when they are 'string'. Here is my code for filtering for reference groups: 

[FormControlEventHandler(formControlStr(InventSite, InventSite_MyField), FormControlEventType::Lookup)]
    public static void InventSite_MAndEDay_OnLookup(FormControl sender, FormControlEventArgs e)

    {
        SysReferenceTableLookup tableLookup = SysReferenceTableLookup::newParameters(tableNum(ReferenceTables), sender);
        Query query = new Query();
        InventSite inventSite;


        QueryBuildDataSource qbds = query.addDataSource(tableNum(ReferenceTables));

        qbds.addRange(fieldNum(ReferenceTables,ReferenceTablesType )).value(queryValue(ReferenceTablesTypeBaseEnum::MyField));

        tableLookup.addLookupField(fieldNum(ReferenceTables, Name ));
        tableLookup.addLookupField(fieldNum(ReferenceTables, Description ));


        tableLookup.parmQuery(query);
        tableLookup.performFormLookup();

        FormControlCancelableSuperEventArgs ce = e as FormControlCancelableSuperEventArgs;
        ce.CancelSuperCall();
    }

Screen-Shot-2021_2D00_10_2D00_18-at-15.29.35.png

Can you help me with this, please?

Thanks and regards...

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

    Your code looks all right to me for an RefRecId field; I suspect that the probem lies somewhere else.

    What do you mean by "I had to convert them into strings ( I had added relations to make them lookup fields)". It sounds strange - and it's probably wrong.

    Can you please confirm the type of InventSite_MyField? Your code expects that is a reference group and it'll fail if not.

    By the way, please ask questions about D365FO in D365FO forums (such as Dynamics 365 Finance Forum), not in the Dynamics AX forum.

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 694

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 646 Super User 2026 Season 1

#3
CP04-islander Profile Picture

CP04-islander 337

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans