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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

SQL Query To Return Employee Names And Their Phone Numbers

(0) ShareShare
ReportReport
Posted on by

I wrote the beloq SQL query to get the phone numbers of all current employees in AX2012. It seems to return most but not all. I also see there's a few records showing details of former employees.

SELECT	a.PERSONNELNUMBER AS [Personnel Number],
							c.FIRSTNAME AS [First Name],
							c.LASTNAME AS [Last Name],
							b.LOCATOR AS [Phone Number],
							b.DESCRIPTION AS [Number Type]
					FROM		HCMWORKER AS a INNER JOIN	
								DIRPERSONNAME AS c ON a.PERSON = c.PERSON 
					LEFT OUTER JOIN	LOGISTICSELECTRONICADDRESS AS b ON c.PERSON = b.PRIVATEFORPARTY
										WHERE CAST(c.VALIDTO AS DATE) = '21541231'


I think the issue comes from an incorrect link between the HCMWORKER and LOGISTICSELECTRONICSADDRESS.

Can anybody please advise the correct way to query this information?

Thanks in advance.

Paul

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mea_ Profile Picture
    60,284 on at
    RE: SQL Query To Return Employee Names And Their Phone Numbers

    Hi runnerpaul,

    You can try to use "DirPartyContactInfoView" view instead of LOGISTICSELECTRONICADDRESS.

    Try join them next way :

    FROM HCMWORKER AS a INNER JOIN

       DIRPERSONNAME AS c

           ON a.PERSON = c.PERSON

       LEFT OUTER JOIN DirPartyContactInfoView AS b

           ON c.PERSON = b.PARTY

    WHERE CAST(c.VALIDTO AS DATE) = '21541231'

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

#1
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#1
Guy Terry Profile Picture

Guy Terry 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans