Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Delaying the Step Execution of a Plugin

Posted on by 11,323

Hi,

I have a Plugin which triggers on an update of a field. The field gets updated around midnight by the SYSTEM and a lot of records get updated around the same time. This causes my plugin to act strangely and I would prefer if I could Delay the execution of my plugin to around 5 mins after the field has been updated as my plugin works 100% when I update the field manually.

Is this even possible?

*This post is locked for comments

  • ashlega Profile Picture
    ashlega 34,475 on at
    RE: Delaying the Step Execution of a Plugin

    It might not be 100% correct.. I think the majority of those timeout issues are caused by all sorts of database locks which may happen in the plugins when lots of them are running at the same time (one plugin will update a record, another one will need to read from it.. something along those lines). It's not just the number of plugins that's causing the timeouts

  • Suggested answer
    Indika Abayarathne Profile Picture
    Indika Abayarathne 671 on at
    RE: Delaying the Step Execution of a Plugin

    If you have very large number of records to trigger a plugin at the same time, you will end up with a timeout. It will trigger the plugin for very first set of records but others will get failed.

    5 minutes delay will not be a good option as even after 5 mintutes you will face the same issue.

    I am also thinking of a batch process to perform the plugin's job.

  • ashlega Profile Picture
    ashlega 34,475 on at
    RE: Delaying the Step Execution of a Plugin

    Hi Thomas,

     I think you'll need to dig into "why" it acts strangely rather than into how to delay it. Chances are, it will start acting strangely again 5 minutes after midnight if you don't figure out the reason why..

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Delaying the Step Execution of a Plugin

    The most is to set the plugins as async plugins, but that won't guarantee the 5 mins interval. If your plugins is not time critical, try change it to custom WFA and add it as a step after some timeout condition in the same workflow.

    What could be the use case? To make it scalable of course batch job will be better solution.

  • David Jennaway Profile Picture
    David Jennaway 14,063 on at
    RE: Delaying the Step Execution of a Plugin

    As per the previous post, maybe using a workflow with a wait is an option. If all instances have a 5 minute wait, they may all start processing at the same time, so the benefit would be from running this asynchronously, rather than the delay.

    It may be simpler to just have your plugin run asynchronously. In most cases this won't affect your code, though you would need to change the code if it runs on a pre-step, or if you rely on changing the OutputParameters

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Delaying the Step Execution of a Plugin

    You can use a background workflow instead. There you can apply waiting of 5 mins and then run the code.

  • Guido Preite Profile Picture
    Guido Preite 54,081 Super User 2024 Season 1 on at
    RE: Delaying the Step Execution of a Plugin

    what do you mean by "act strangely"? or the plugin works or the plugin doesn't work. what the plugin is doing? the fact that doesn't work is caused by many records updated at the same time? (for example you are doing a retrieve multiple and get a not exact total count?)

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