Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Fire the update event for the historical data

Posted on by 395

Hi,

Can any one help me how to fire an update event without affecting the data. Here is the scenario. Currently we have data in system there is a logic change for couple of fields on the Account form. This logic is related to Opportunities and Leads, we show the total opportunities + Leads count according to requirement and their total. We registered a plug-in some time back on Plug in Create/Update/Delete and now there is a new requirement so we have updated the plug-in logic. Every thing works fine for the new records and for the historical data it doesn't show the new value on account form until unless we save the opportunity record.

I tried to change one field value and imported the data thinking that it fires the update plug-in but it did not change the values. Can some one suggest a better approach to implement with a better design. Can this be done with a workflow or any other approach?

*This post is locked for comments

  • tw0sh3ds Profile Picture
    tw0sh3ds 5,600 on at
    RE: Fire the update event for the historical data

    Great to know, you managed to complete the task. Please mark this topic as verified to close it.

  • Suggested answer
    Srini20 Profile Picture
    Srini20 395 on at
    RE: Fire the update event for the historical data

    Thank you. I thought similarly and created a sample program to finish the work.

  • Suggested answer
    Srini20 Profile Picture
    Srini20 395 on at
    RE: Fire the update event for the historical data

    Sorry Pawel, I thought I did not explained clearly :(.

    Thank you for the input, I was able to proceed with program.

  • Suggested answer
    tw0sh3ds Profile Picture
    tw0sh3ds 5,600 on at
    RE: Fire the update event for the historical data

    Hi,

    I understand everything, I'm not sure why you explained everything that was already in the first post and did not refer to anything that I wrote in mine :) As I said - if you changed value of a field and run import, then plugin must have been triggered. If it did not update the data then it must be something wrong with the plugin. Maybe you can share some code (simplified of course). You have to check if it does not check for Depth bigger than 1. Also make sure that the plugin triggers every time - not only on some specific fields.

    As I wrote in my first post - you should write a simple console app that will do the job.

  • Suggested answer
    ScottDurow Profile Picture
    ScottDurow 50,177 on at
    RE: Fire the update event for the historical data

    This is quite a common problem that I run into.

    Importing records without changing any field values won't work because the import checks if the record data is different.

    You will either have to change a dummy value on the records and import (presuming that you have not registered your plugin with any filtering attributes) - or you could create a small program to run the logic manually and update the records using the sdk webservices rather than the plugin.

    Hope this helps,

    Scott

  • Srini20 Profile Picture
    Srini20 395 on at
    RE: Fire the update event for the historical data

    Hi Pawel,

    Currently there are no imports. Here is what we have done.

    There is a field on Account Page which shows some value by calculating the logic of Opportunity & Lead. When we imported all the data imported successfully during release 1 and the field which exist on Account showing fine and it was calculating the value as per the release 1 requirements. Field which exist on Account we populated this by registering a plug-in on Opportunity & Lead for all the 3 events Create/Update/Delete. Ex: Show the number of associated Opportunities & Leads to a particular account.

    Recently we got a requirement to update the logic which we implemented as per the requirement. After implementing this logic every thing works fine if we create new records or open the existing record and update some value but the field which exist on Account is not showing the value out of the new logic for the historical records. If I manually open the opportunity or lead record and update some value then it reflects the correct value on Account field.

    Currently I am not importing any thing, I believe my import went fine but I am trying to figure out how to update the field value for the existing records.

  • Verified answer
    tw0sh3ds Profile Picture
    tw0sh3ds 5,600 on at
    RE: Fire the update event for the historical data

    Hi,

    Importing must trigger the plugin, so you did something wrong. It's hard to diagnose something like that without access to code, so I will be guessing - I'm guessing that in your plugin you are checking the Depth to be not bigger than 1, in that case this will not be triggered when importing. Also maybe your plugin fires only when you are updating specific field not any field?

    On the other hand, when I face similar problem (updating historical data) I never go for approach of triggering plugins to do the job for me. I would go for a simple console application that will just retrieve all historical records and for every record will just run the logic and save it with proper value. You don't have to rewrite the logic - if you wrote your plugin correctly it can be probably copy-pasted into your console application (of course instead of getting IOrganizationService from PluginContext you have to establish CRM connection). Writing application like that is 15 minutes work (having in mind that you ar4e copy-pasting logic from existing plugin). If you never wrote application that connects to CRM, use simplified connection:

    msdn.microsoft.com/.../jj602970.aspx

    this is really easy and you can forget about good practices of programming and whatever - just create a new Console App and do everything in Main() function - you will run it only once...

    Of course you should first run it on some single record to check if it works ok and if it does just retrieve all records to process and run the logic.

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

Featured topics

Product updates

Dynamics 365 release plans