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

Notifications

Announcements

No record found.

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
    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
    300,911 Super User 2025 Season 2 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans