Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Answered

C# difficulty retrieving Audit history details, getting

(0) ShareShare
ReportReport
Posted on by 5

Hello,

I set up a question over at Stackoverflow concerning my code to pull the audit history of an entity, However it is returning an exception and I don't know how to correct it.

https://stackoverflow.com/questions/67028578/ms-dynamics-365-c-sharp-audit-history-keynotfoundexception

I am able to connect and enter the loop but the first pass returns no values and the second throws the exception

System.Collections.Generic.KeyNotFoundExemption: The given key was not present in the dictionary.

Now, as far as I know, I'm using the correct AttributeLogicalName but I don't know how to handle this exception.

Any ideas?

I'm not a programmer by trade and we're left to our own devices because IT doesn't see this as a priority project, but it has to get done so please be gentle. 

  • Suggested answer
    Nishant Rana Profile Picture
    11,325 Microsoft Employee on at
    RE: C# difficulty retrieving Audit history details, getting

    Make sure correct schema name of the attribute is used along with null check..

  • Community Member Profile Picture
    on at
    RE: C# difficulty retrieving Audit history details, getting

    Hi Partner,

    Has the problem been solved? Any updates?

    Please click Yes under "Did this answer your question?" to close this thread.

     pastedimage1618392869990v1.png

    Thanks. 

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • Verified answer
    Community Member Profile Picture
    on at
    RE: C# difficulty retrieving Audit history details, getting

    Hi Sweepster,

    You can check the code that following link provide:

    How to get Audit Details from MS CRM (C#.NET) – Friyank Parikh Blog (wordpress.com)

    Using RetrieveRecordChangeHistoryRequest to get Audit Detail in Dynamics 365 CE – Nishant Rana's Weblog

    Or you can try to use Audit History Extractor (Audit History Extractor  · XrmToolBox) to extract Audit history details for one entity, which is one tool for XRM ToolBox.

    (1) Download XRM ToolBox. https://www.xrmtoolbox.com/

    (2) Once you have downloaded and installed it, then connect to you crm environment.

    (3) Go library to install Audit History Extractor.

    pastedimage1618212953056v1.png

    (4)Open Audit History Extractor.

    you need click 'Get entities' button to load all entities that has enabled audit, then you can choose one entity and set other filters.

    Clicking 'preview data' button, you can view date in the right pane.

    pastedimage1618213103320v2.png

    Or you can refer following link to get the audit log of an entity by using a web API:

    (+) How to get the audit log of an entity in CRM 2016 using a web API - Microsoft Dynamics CRM Forum Community Forum

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

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

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 51 Most Valuable Professional

#2
Ramesh Kumar Profile Picture

Ramesh Kumar 42

#3
David Shaw_UK Profile Picture

David Shaw_UK 27

Featured topics

Product updates

Dynamics 365 release plans