Find References in dynamics 365 for operations using PowerShell

Just wanted to share quick note about finding references from PowerShell . In dynamics 365 for operations you can use find references or cross references (Previous version AX 2012) from visual studio . Suppose you want to find In which objects a particular enum is used then in visual studio you can just click on that enum and click find references and it gives you list of objects where that particular Enum is used .
With following PowerShell command along with object name you can see line of code where that particular enum is used with line number. To get the result perform following steps.
First navigate to package folder so that you can refine your search. In my example I am using application suite and in my case pacakesLocalDirectory is at J drive . It can be in different drive as well. With updates 12 machines I can see its moved to K drive.
cd J:\aosservice\PackagesLocalDirectory\ApplicationSuite

And then use following command to search
Get-ChildItem -Recurse -Filter *.xml | Select-String -Pattern "SalesStatus"
You can see on below screenshot you can where that enum is used along with line of code and line number.



Instead of clicking each object one by one to see code you get to see what you want in one look. I found this very useful in my case where I need to find  in the code where it was getting assigned to specific value in specific scenario , quickly I can copy this result in notepad and check if == operator is used we are doing comparison and if its = we are assigning value to enum, which narrows down my search.

Comments

Popular posts from this blog

Running runnable class through URL in Dynamics 365 for Operations

D365FO Use of FileUpload control to Read CSV file

D365FO Send Report as email attachment