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)

Trigger a Plugin

(0) ShareShare
ReportReport
Posted on by 1,655

I Registered a plugin, and i need to trigger, Tell me how to trigger a plugin in ms crm 2013 points wise.  

*This post is locked for comments

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

    CRM platform automatically triggers plugin based on user’s action. Let’s say if you have registered a plugin on create of an account, then it’ll trigger on every account creation and whatever logic you have written inside plgin will execute.

    If you want to debug the plugin, there are multiple ways to do it.

    1 – use w3wp process, if your dev instance is on CRM server, (need to copy required dll and pdb file in server/bin/assembly folder)

    2 – use plugin profiler available in Plugin Registration Tool.

    Hope this helps.

    Thanks,

    Vijay

  • Ezorif Profile Picture
    1,655 on at

    I Created a Plugin but not firing, If u wish send me the code for firing a plugin while creation of entity

  • Vijay Waghmare Profile Picture
    on at

    do you mean by firing plugin on creation of entity or entity record?

    plugin will not fire on entity creation but surely will fire on record creation

  • Ezorif Profile Picture
    1,655 on at

    Creation of Entity Record only, I watched a Video and after creation of a new record it shows the activity as created and fired, But in my code it was not showing in activity.

  • Vijay Waghmare Profile Picture
    on at

    How you have registered plugin through "Plugin Registration Tool" for entity?

    Provide your plugin code here with registered step screenshot.

  • Ezorif Profile Picture
    1,655 on at

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.ServiceModel;

    using Microsoft.Xrm.Sdk;

    namespace Microsoft.Crm.Sdk.Samples

    {

       public class PluginDemo : IPlugin

       {

           public void Execute(IServiceProvider serviceprovider)

           {

               IPluginExecutionContext context = (IPluginExecutionContext)serviceprovider.GetService(typeof(IPluginExecutionContext));

               IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceprovider.GetService(typeof(IOrganizationServiceFactory));

               ITracingService tracingservice = (ITracingService)serviceprovider.GetService(typeof(ITracingService));

           if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)

    {

    Entity entity = context.InputParameters["Target"] as Entity;

    if (entity.LogicalName != "account")

    {

    return;

    }

    Entity followup = new Entity();

    followup.LogicalName = "task";

    followup.Attributes = new AttributeCollection();

    followup.Attributes.Add("subject", " created via plugin");

    followup.Attributes.Add("description", "Added Test Description");

    followup.Attributes.Add("schedulestart", DateTime.Now.AddDays(3));

    followup.Attributes.Add("scheduledend", DateTime.Now.AddDays(5));

    if (context.OutputParameters.Contains("id"))

    {

    Guid regardingobjectid = new Guid(context.OutputParameters["id"].ToString());

    string regardingobjectidType = "account";

    followup["regardingobjectid"] = new EntityReference(regardingobjectidType, regardingobjectid);

    }

    service.Create(followup);

           }

           }

       }

    }

    This is my code

  • Vijay Waghmare Profile Picture
    on at

    Plugin code looks fine. Make sure you have registered your plugin on create of account and in Asynchronous Mode-Post Operation.

    Check the "System Jobs" under "Settings" after account creation for any error in plugin.

  • Suggested answer
    Vijay Waghmare Profile Picture
    on at

    Plugin code looks fine. Make sure you have registered your plugin on create of account and in Asynchronous Mode-Post Operation.

    Check the "System Jobs" under "Settings" after account creation for any error in 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