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)

How to get a list of companies based on specific user

(0) ShareShare
ReportReport
Posted on by

How to get a list of companies based on specific user ?

*This post is locked for comments

I have the same question (0)
  • Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Hi,

    What do you mean exactly?

    The companies somebody has access to or the one he worked in, etc.?

    Would be great if you could clarify.

    Thanks,

    Ludwig

  • Verified answer
    Jie G Profile Picture
    Microsoft Employee on at

    Hi Gnanaprakash,

    Please try following code:

    UserId userId = curUserId();
    
    CompanyInfo companyInfo;
    OMUserRoleOrganization oMUserRoleOrganization;
    container result;
    
    while select companyInfo
        exists join oMUserRoleOrganization
            where oMUserRoleOrganization.OMInternalOrganization == companyInfo.RecId
                && oMUserRoleOrganization.User == userId
    {
        result += [companyInfo.Name, companyInfo.DataArea];
    }
    
    if (!result)
    {
        // no specific company for user --> all
        while select companyInfo
        {
            result += [companyInfo.Name, companyInfo.DataArea];
        }
    }


  • Community Member Profile Picture
    on at

    Thanks for reply,

    Yes i want the list of companies somebody has access to. How can i get that through x++ code?

  • Community Member Profile Picture
    on at

    Hi Ada Ding,

    Does the above code supposed to get the list of companies somebody has access to?

    When I am running it in a job, I am not get expected result.

  • André Arnaud de Calavon Profile Picture
    305,182 Super User 2026 Season 1 on at

    Hi Gnanaprakash,

    If you don't have the correct result, you can also have a look at my example for restricting access to legal entities. The examples do contain some logic to determine legal entity access in general or per role. kaya-consulting.com/extensible-data-security-examples-secure-by-legal-entity

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 April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 24

#2
Michel ROY Profile Picture

Michel ROY 14

#3
Jagadabi Profile Picture

Jagadabi 6

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans