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 CRM (Archived)

Can an action be invoked from a plugin asynchronously?

(0) ShareShare
ReportReport
Posted on by

Currently in Dynamics CRM 2015 I have a plugin invoking an action using the following snippet

 OrganizationRequest request = new OrganizationRequest("new_testaction");                
                request["Message"] = message;
                request["MessageType"] = messageType.ToString();
                request["TimeStamp"] = DateTime.Now;               

                // execute the request
                service.Execute(request);         


I don't really care when this execution completes and don't need a response. I'm just trying to log some information and would prefer it to be done asynchronously. 

I came across the 'ExecuteAsyncRequest' type but am not sure if this can be used for invoking actions. The documentation states that it can only be used for ImportSolutionRequest requests. Is there another way I can invoke an action asynchronously from a plugin in CRM 2015?

*This post is locked for comments

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

    Ideally even if the plugin encounters an exception which usually would cause the main operation to rollback as it is in a DB transaction, I would like to log some info asynchronously to an error entity. The problem is that because CRM rolls back the transaction even the error entity doesn't get written to. I was hoping to have an async. call ensure that that error entity gets created even if the db transaction rolls back and the actual plugin work is not performed.

  • Suggested answer
    Mithilesh Kumar Profile Picture
    10,047 on at

    Hi Crainialsurge,

    1. You can register your plugin to execute Asynchronously.

    2. You need to catch the Exception and then in the Catch block execute couple of lines of code to write error message to your Custom Error Entity.

    Hope that helps

    Thanks

  • cranialsurge Profile Picture
    on at

    Unfortunately, this is an existing plugin for which I need to log something and it is registered to be synchronous and needs to stay that way.

  • Suggested answer
    Ben Mueller Profile Picture
    on at

    I do not believe it is possible to execute an asynchronous organization request from a synchronous plugin.

    You mentioned that the overall plugin needs to remain synchronous. However, in your scenario, would it be possible to create a second plugin that executes asynchronously on the same trigger?

    For example, on create of a specific entity (or whatever your case is), execute the already existing synchronous plugin AND a newly created asynchronous plugin.

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 CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans