Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

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

(3) ShareShare
ReportReport
Posted on by 35

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!"

 

Categories:
  • Verified answer
    Mohammed Rafe Profile Picture
    35 on at
    MainAccount Lookup Field Not Showing Data for Specific Users in Custom D365 F&O Screen
    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.
  • Waed Ayyad Profile Picture
    7,698 Super User 2025 Season 1 on at
    MainAccount Lookup Field Not Showing Data for Specific Users in Custom D365 F&O Screen

    Hi, 

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

    Thanks,

    Waed Ayyad

  • André Arnaud de Calavon Profile Picture
    292,686 Super User 2025 Season 1 on at
    MainAccount Lookup Field Not Showing Data for Specific Users in Custom D365 F&O Screen
    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.
  • Martin Dráb Profile Picture
    231,639 Most Valuable Professional on at
    MainAccount Lookup Field Not Showing Data for Specific Users in Custom D365 F&O Screen
    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).
  • Suggested answer
    Waed Ayyad Profile Picture
    7,698 Super User 2025 Season 1 on at
    MainAccount Lookup Field Not Showing Data for Specific Users in Custom D365 F&O Screen
     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

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,686 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,639 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans