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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Using C# plugin how to preserve the previous 'ModifiedOn' value when the statecode changes from 0 (Open) to 1 (Completed) for a entity record?

(0) ShareShare
ReportReport
Posted on by 57

Hi,

I want to use a C# plugin in D365 to preserve the previous 'ModifiedOn' value when the statecode changes from 0 (Open) to 1 (Completed) for a entity record

Please provide a example of how to implement this functionality.

Thanks in advance.

I have the same question (0)
  • AriaConsulting Profile Picture
    2 on at

    Hi Vivek,

    I would first ask why you want to using a plugin for this? Whether you're using on-prem or cloud D365 (I'm assuming you're referring to D365 CE, not BC and definitely not F&O), plugins should be a last resort.  And if you only want to preserve a single data value like that you could easily create a custom field on the entity for the previous value and have an automated cloud flow in Power Automate that triggers when the ModifiedOn value changes and pushes the previous value to the new field.

    One thing that a lot of people haven't run into with the Horrified UI (ooops, Unified UI), is that, for whatever insane reason, MS architected it using a procedural pattern where plugins sit chronologically on top of each other.  For instance, let's say you develop and deploy this plugin that will obviously tie to pretty much all the major entities like Account, Contact, lead, and so on. Then a few months down the road, for example, you put in another plugin.  Whether that is something you develop or an ISV.  Then, let's say, 6 months after that, you come across a great ISV solution that your org really wants to use but when you test it it conflicts with the first plugin.  So, you need to remove the plugin.  Guess what though?  You can't remove the first one until you remove the SECOND one. And loose whatever data the 2nd one managed.  And this actually happens even with MS' own apps.

    If you want to go to the effort I went through, you can actually see this for yourself.  Start with a vanilla Sales Pro environment.  Add D365 marketing.  Create a plugin that references the major entities like contacts, leads, accounts, etc.  Create some data.  The, add in an ISV solution that also references those entities.  Then, try to remove the Marketing app.  MS support gave up trying to remove the Marketing app (which is THEIR marketing app!) from my environment after 3.5 months of support effort.

    So, that was the first thing.  The second thing is that are you aware that, if you have auditing enabled for the entity, you can access the audit logs through M365 Compliance Center (not D365) and the logs will give you that ModifiedOn date change info?

  • Suggested answer
    Nya Profile Picture
    29,060 on at

    Hi,

    It is recommended to achieve your request with a Flow.

    Here is an example which will output the Modified On field when an opportunity’s Status Reason turns into Won.

     pastedimage1627960539479v1.png

    And when an opportunity is Closed as Won, the Modified On will be output as the following:

     pastedimage1627960545183v2.png

    Of course, you can also create a custom field and fill the field with this value via the flow.

  • AriaConsulting Profile Picture
    2 on at

    Yeah, I kinda said that already Nya.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
iampranjal Profile Picture

iampranjal 41

#2
Martin Dráb Profile Picture

Martin Dráb 36 Most Valuable Professional

#3
Satyam Prakash Profile Picture

Satyam Prakash 35

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans