Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

How to capture and store a field each time it changes

Posted on by 2,645

If an Account name changes, I need to send an email to some people.  In the email I need to let them know what the original name was and then what the new name is.  How can I capture this? 

  • AriaConsulting Profile Picture
    AriaConsulting 2,655 on at
    RE: How to capture and store a field each time it changes

    LOL!

  • meelamri Profile Picture
    meelamri 13,204 User Group Leader on at
    RE: How to capture and store a field each time it changes

    Right, good point :)

  • AriaConsulting Profile Picture
    AriaConsulting 2,655 on at
    RE: How to capture and store a field each time it changes

    Uhhh meelamri, that's exactly what Wahaj Rashid suggested......

  • Suggested answer
    meelamri Profile Picture
    meelamri 13,204 User Group Leader on at
    RE: How to capture and store a field each time it changes

    Hi,

    There is also an approach that requires no code:  

    Create a technical field (OldName)

    A Workflow that runs before the modification of the Name field, which will store the current value of the name in the technical field (OldName)

    A second Workflow that will run after the modification and that will retrieve the old value from the created technical field. So you can send your mail with both values.  

  • AriaConsulting Profile Picture
    AriaConsulting 2,655 on at
    RE: How to capture and store a field each time it changes

    USA80,

    There are even additional options to the ones that Wahaj Rashid kindly provided. However, this method gives you the option to report on/action changes from any 365 service that is enabled for auditing (including SharePoint and Exchange even).  In any case you have to have auditing turned on and configured.  Once auditing is on you can use the Office 365 Management Activity API to query the M365 (not D365) Compliance Center, which is where the log data actually ends up.  It goues there as otherwise you would chew through your D365 storage quota very quickly indeed!  Once you connect to the API and format the query(ies) you want, you can use a webhook for notifications.  Which can obviously be in the format of email.  The bonus with this is that if you have PBI licenses you can get double the benefit from the same work by also hooking it up to PowerBI.  And if you want to get even more fancy you could create a running history in a custom table and then add said custom table to the D365 form as a subgrid.

    If you want to take on an entire project of effort you could go all the way to connecting the audit logs to Azure Sentinel (Microsoft's SIEM tool) and then you can get such a deluge of information d insight it would likely make your head hurt.  But that's probably 3 or 4 orders of magnitude more than you're wanting .

  • Suggested answer
    Wahaj Rashid Profile Picture
    Wahaj Rashid 11,319 on at
    RE: How to capture and store a field each time it changes

    Hi,

    Thank you for your query.

    Ideally, you should:

    • Enable Auditing.
    • Create a workflow to send an email with the Account link (Dynamics Record URL), whenever the account name changes.
    • User clicks on the Record, the account will open, and then they can see Audit History for the new and old value

    If it is necessary to send old and new name in the Email, you can use either a real-time workflow (with a temp field or use a plugin with pre and post-image).

    As a No-Code solution, use a real-time workflow with a temp field, see the following article:

    Real-Time Workflow: Capturing Pre and Post Values | PowerObjects

    For plugins, you need to write a plugin that:

    • Triggers on Account Update (Pre-stage).
    • Register Pre and Post Images with the account name field.
    • Now you will get the pre and post values of the account name in the plugin, send an email using SendEmailRequest.

    Here is a sample:

    Dynamics 365 Plugins - Pre and Post Images - Carl de Souza

    To send an email using C#/plugin:

    Send a Dynamics 365 Email using C# - Carl de Souza

  • Suggested answer
    Ramit Paul Profile Picture
    Ramit Paul 22,300 Most Valuable Professional on at
    RE: How to capture and store a field each time it changes

    If your question was related to MSD365 FO, then you can use changed base alert feature.

    docs.microsoft.com/.../alerts-overview

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans