Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Get the Current Active Company RecId in Dynamics AX.

(0) ShareShare
ReportReport
Posted on by 125

Any body tell me how to get the Current Active Company RecId in Dynamics AX 2012.

I want to set range in query data source on the base of RecId,but dont know how to do.

08021.Capture.PNG

In the value field,i want to pass current active company RecId.

*This post is locked for comments

  • udaY-ch Profile Picture
    4,643 on at
    RE: Get the Current Active Company RecId in Dynamics AX.

    Use this LegalEntity legalEntity =  CompanyInfo::findRecId(CompanyInfo::current()).RecId;

  • Faran Baig Profile Picture
    125 on at
    RE: Get the Current Active Company RecId in Dynamics AX.

    Udhaya,compiler is giving an error,Operand types are not compatible with the operator.

    73202.Capture.PNG

    As this is init method,so i think this may cause issue as instance is initialized so will get RecId of fisrt opened company in this

    CompanyInfo::find().RecId  case?

  • udaY-ch Profile Picture
    4,643 on at
    RE: Get the Current Active Company RecId in Dynamics AX.

    LegalEntity legalEntity =  CompanyInfo::findRecId(CompanyInfo::current());

  • Faran Baig Profile Picture
    125 on at
    RE: Get the Current Active Company RecId in Dynamics AX.

    Udhaya my role is working fine,but a single problem is that,query takes the RecId of first company when ax opens up first time,and showing correct data of that company,but when i changes the company,it is still showing the data filtered on the basis of previous company RecId,now how to refresh and pass the next company RecId(if i change company)?

  • Verified answer
    udaY-ch Profile Picture
    4,643 on at
    RE: Get the Current Active Company RecId in Dynamics AX.

    HI,

    You need to create a range. Take a look at the query KanbanMultiKanbanReceive

    /Uday.

  • Faran Baig Profile Picture
    125 on at
    RE: Get the Current Active Company RecId in Dynamics AX.

    Udhaya Facing an issue in line 5,query worked,but this time nothing is showing,may be due to this stack trace.

    76202.Capture.PNG

  • udaY-ch Profile Picture
    4,643 on at
    RE: Get the Current Active Company RecId in Dynamics AX.

    Try to clear the AUC files and clear usage data and try checking the same. It should work.

  • Faran Baig Profile Picture
    125 on at
    RE: Get the Current Active Company RecId in Dynamics AX.

    Udhaya i have used same query coming under Form HcmWorkerListPage Data Sources named as HcmWorkerListPage and added above method in init method,

    but not getting desirable results.Means by logging from other user and assigning my role,it is still showing all workers in Retail>Workers  in any company. Although i have removed System Administrative role.

  • udaY-ch Profile Picture
    4,643 on at
    RE: Get the Current Active Company RecId in Dynamics AX.

    Yes. This would solve your issue.

  • Faran Baig Profile Picture
    125 on at
    RE: Get the Current Active Company RecId in Dynamics AX.

    Udhaya Just i need this in init method of query,no need of execute query method or any other?

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics AX (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 100 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 46

#3
shanawaz davood basha Profile Picture

shanawaz davood basha 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans