Announcements
Hi,
I want to get all worker and all companies so that i can't able current company and all companies.
Below my code.
while select hcmEmployment where (hcmEmployment.LegalEntity != CompanyInfo::find().RecId && hcmEmployment.LegalEntity == CompanyInfo::current()) outer join hcmWorker where hcmWorker.RecId == hcmEmployment.Worker { Info(strFmt("%1", CompanyInfo::getDataArea(hcmEmployment.LegalEntity), hcmWorker.PersonnelNumber)); }
Hi Waytod365,
Can you elaborate on your actual business requirement? I can't understand what should be the outcome of your select statement.
What is the current and expected outcome?
Note that the coding will be better readable if you use the rich formatting and then choose Insert > Code.
Thanks for your reply,
I want to get all workers all companies.
Hi waytod365,
All workers can be exported by HcmEmployment table. It has information about the legal entity and date interval that they are active.
I think you want code like this:
while select hcmEmployment join hcmWorker where hcmWorker.RecId == hcmEmployment.Worker { info(strFmt("%1 - %2", CompanyInfo::getDataArea(hcmEmployment.LegalEntity), hcmWorker.PersonnelNumber)); }
Or maybe this:
while select hcmWorker outer join hcmEmployment where hcmEmployment.Worker == hcmWorker.RecId { info(strFmt("%1 - %2", CompanyInfo::getDataArea(hcmEmployment.LegalEntity), hcmWorker.PersonnelNumber)); }
By the way, please use Insert > Code (in the rich-formatting view) to paste source code.
Thanks for your reply sir,
Yes, i tried but both code only show USMF company related worker.
I want to see all company legal entity and all workers. How can I get this?
I want like :-
Employment.legalEntity != CompanyInfo::find().recid and companyInfo:: current (). How can I check both?
There is nothing more to do. Both HcmWorker and HcmEmployment are shared tables and therefore the query returns data from all companies of the current partition.
I suspect the probem in your assumptions. How did you determine that the user has one more employment in another company valid for current date, which should therefore be returned by this query?
Your code makes no sense to me. You're trying to get employment from legal entity that is or isn't the current company, which is always true and therefore the result is the same not having any condition at all. Please stop trying to use this useless code.
Also, you're wrong if you believe that CompanyInfo::find().RecId and CompanyInfo::current() can you give you two different things.
Actually, I'm lost here. The requirement is "get all workers all companies". In that case, why do you want to add "Employment.legalEntity != CompanyInfo::find().recid and companyInfo:: current ()."? In my thoughts, all workers, all companies should not have any additional "where clauses".
The code suggestion from Martin looks good to me, unless the requirement is different.
Sorry for the late reply Martin sir,
My bad i noted.
Actually what I want to get if the worker belong to two company in this case that worker and legal entity name only i want to get so that need to change above your code ?
If not please give me some example on this.
Thanks
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.
Congratulations to our community stars!
Expanding mentorship, skilling, and AI innovation
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 263 Most Valuable Professional
André Arnaud de Cal... 257 Super User 2026 Season 2
Subra 235 Super User 2026 Season 2