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, ...
Suggested Answer

MainAccount Lookup Field Not Showing Data for Specific Users in Custom D365 F&O Screen

(3) ShareShare
ReportReport
Posted on by 58

I have created a customized screen in Dynamics 365 F&O named 'Create Salaries GL.' Recently, I added two new lookup fields, 'MainAccount' and 'SchoolDim,' to the screen. While the 'SchoolDim' lookup works perfectly and displays data for all users, the 'MainAccount' lookup does not display any data for certain users, despite having valid data in the table.

I have ensured that the affected users have the appropriate roles and permissions for this screen, but the issue persists. Below is the code I used for the lookup logic for both fields:

MainAccount Lookup Code:
    [Control("String")]
    class MainAccountList
    {
        public void lookup()
        {
            MainAccountList.text("");
            SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(HcmWorker), this);
            Query query = new Query();
            QueryBuildDataSource qbds;
            QueryBuildRange qbr;

            qbds = query.addDataSource(tableNum(HcmWorker));
            qbds.addGroupByField(fieldNum(HcmWorker, MainAccountId));
            qbr = qbds.addRange(fieldNum(HcmWorker, MainAccountId));
            qbr.value(strFmt('!%1', queryValue('')));
            sysTableLookup.addLookupField(fieldNum(HcmWorker, MainAccountId));
            sysTableLookup.parmQuery(query);
            sysTableLookup.performFormLookup();
        }
    }

SchoolDim Lookup Code:
[Control("String")]
    class SchoolList
    {
        public void lookup()
        {
            SchoolList.text("");
            SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(SalaryManagement_EntryData_Sti), this);
            Query query = new Query();
            QueryBuildDataSource qbds;
            QueryBuildRange qbr;
    
            qbds = query.addDataSource(tableNum(SalaryManagement_EntryData_Sti));    
            qbds.addGroupByField(fieldNum(SalaryManagement_EntryData_Sti, School));
            query.queryType(QueryType::Join);
    
            qbr = qbds.addRange(fieldNum(SalaryManagement_EntryData_Sti, School));
            qbr.value(strFmt('!%1', queryValue('')));
            qbr = qbds.addRange(fieldNum(SalaryManagement_EntryData_Sti, DataAreaId));
            qbr.value(strFmt('%1', curExt()));
                
            sysTableLookup.addLookupField(fieldNum(SalaryManagement_EntryData_Sti, School));
    
            sysTableLookup.parmQuery(query);
            sysTableLookup.performFormLookup();
        }
    }

 

Note: The MainAccount field is based on the HcmWorker table, while the SchoolDim field is based on the SalaryManagement_EntryData_Sti table (a custom table).

Attached is a screenshot of the issue for further clarification.

Could anyone advise on why the MainAccount lookup might not be displaying data for some users and how to resolve this issue?

Thank you in advance for your assistance!"

 

bb.png
Categories:
I have the same question (0)
  • Suggested answer
    Waed Ayyad Profile Picture
    9,061 Super User 2026 Season 1 on at
     Hi,
     
    Did you try to trace the code to see the query? If not, then trace the code and check the query and try to use it in SQL, and check the result of it.

     Also try to use this qbr.value(SysQuery::valueNot(“”)); instead of  qbr.value(strFmt('!%1', queryValue('')));
     

    Thanks,

    Waed Ayyad

    If this helped, please mark it as "Verified" for others facing the same issue

  • Martin Dráb Profile Picture
    238,743 Most Valuable Professional on at
    Let me simplify your code a bit (and ignore the method that works correctly).
    Query query = new Query();
    
    QueryBuildDataSource qbds = query.addDataSource(tableNum(HcmWorker));
    qbds.addGroupByField(fieldNum(HcmWorker, MainAccountId));
    
    QueryBuildRange qbr = qbds.addRange(fieldNum(HcmWorker, MainAccountId));
    qbr.value(SysQuery::valueNotEmptyString());
    
    SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(HcmWorker), this);
    sysTableLookup.addLookupField(fieldNum(HcmWorker, MainAccountId));
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
    Do the user see the data in the Workers form?

    What can you tell us about the MainAccountId field? Isn't it a surrogate key? If so, you'd need to handle the replacement fields too (such as grouping by them).
  • André Arnaud de Calavon Profile Picture
    303,128 Super User 2026 Season 1 on at
    Hi Mohammed,
     
    There can be a security policy active which is restricting the number of records for particular users. A security policy is an AOT object part of the Extensible Data Security (XDS) framework in Dynamics 365 F&O.
  • Waed Ayyad Profile Picture
    9,061 Super User 2026 Season 1 on at

    Hi, 

    Is your issue resolved? If yes, mark the answers that helped you as verified

    Thanks,

    Waed Ayyad

  • Suggested answer
    Mohammed Rafe Profile Picture
    58 on at
    Thank you all for your responses,
    I have resolved the issue, which was related to permissions on the 'HcmWorker' table. It turns out that a role was restricting some users from accessing this table, preventing them from viewing or editing data in it.
    When attempting to display fields from the 'HcmWorker' table, the restricted users were unable to see any data. Thank you again for your help and suggestions.

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

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

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 378

#3
Diego Mancassola Profile Picture

Diego Mancassola 255

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans