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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

Plugin not fired nor thrown any error

(0) ShareShare
ReportReport
Posted on by

I used the below for code for "Create Contact" which then gives text in "Job Title" field. But by doing this plugin is not giving error nor throwing error.
Kindly help me on this issue.




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ServiceModel;
using Microsoft.Xrm.Sdk;


namespace MyPlugins
{
public class HelloWorld : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
// Obtain the tracing service
ITracingService tracingService =
(ITracingService)serviceProvider.GetService(typeof(ITracingService));

// Obtain the execution context from the service provider.
IPluginExecutionContext context = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext));

// Obtain the organization service reference which you will need for
// web service calls.
IOrganizationServiceFactory serviceFactory =
(IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

// The InputParameters collection contains all the data passed in the message request.
if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is Entity)
{
// Obtain the target entity from the input parameters.
Entity entity = (Entity)context.InputParameters["Target"];

try
{
// Plug-in business logic goes here.

//Read data from attributes
string businessPhone = entity.Attributes["telephone1"].ToString();

//Assigning data to attributes
entity.Attributes.Add("jobtitle", "Developer Contact: " + businessPhone); }

catch (FaultException<OrganizationServiceFault> ex)
{
throw new InvalidPluginExecutionException("An error occurred in FollowUpPlugin.", ex);
}

catch (Exception ex)
{
tracingService.Trace("FollowUpPlugin: {0}", ex.ToString());
throw;
}
}
}
}
}

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Saravana Sastha:

    It seems that you missed this code: service.Update(entity);

    Please try the following code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.ServiceModel;
    using Microsoft.Xrm.Sdk;
    
    
    namespace MyPlugins
    {
    public class HelloWorld : IPlugin
    {
    public void Execute(IServiceProvider serviceProvider)
    {
    // Obtain the tracing service
    ITracingService tracingService =
    (ITracingService)serviceProvider.GetService(typeof(ITracingService));
    
    // Obtain the execution context from the service provider.
    IPluginExecutionContext context = (IPluginExecutionContext)
    serviceProvider.GetService(typeof(IPluginExecutionContext));
    
    // Obtain the organization service reference which you will need for
    // web service calls.
    IOrganizationServiceFactory serviceFactory =
    (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
    IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
    
    // The InputParameters collection contains all the data passed in the message request.
    if (context.InputParameters.Contains("Target") &&
    context.InputParameters["Target"] is Entity)
    {
    // Obtain the target entity from the input parameters.
    Entity entity = (Entity)context.InputParameters["Target"];
    
    try
    {
    // Plug-in business logic goes here.
    
    //Read data from attributes
    string businessPhone = entity.Attributes["telephone1"].ToString();
    
    //Assigning data to attributes
    entity.Attributes.Add("jobtitle", "Developer Contact: "   businessPhone); }
    
    //update entity
    service.Update(entity);
    
    catch (FaultException ex)
    {
    throw new InvalidPluginExecutionException("An error occurred in FollowUpPlugin.", ex);
    }
    
    catch (Exception ex)
    {
    tracingService.Trace("FollowUpPlugin: {0}", ex.ToString());
    throw;
    }
    }
    }
    }
    }

    
                          
  • Suggested answer
    Bipin D365 Profile Picture
    28,995 Moderator on at

    Hello,

    Please register your plugin step in Pre-operation instead of Post Operation.

    Can you please check your plugin step.

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • Saravana Sastha Profile Picture
    on at

    Still No change Steve.

    I followed exactly the same steps in udemy by Satish Reddy for plugin development.

    He used trial versions.

    I followed the exact same step in my lap but with the company's actual testing org and company's emailid . But my plugin is not working nor it is showing any error.

    Do you think the error will be in my side or is it because  of actual company's working org link?

  • Saravana Sastha Profile Picture
    on at

     Bipin Kumar I have chosen pre-operation only.

    I followed exactly the same steps in udemy by Satish Reddy for plugin development.

    He used trial versions.

    I followed the exact same step in my lap but with the company's actual testing org and company's emailid . But my plugin is not working nor it is showing any error.

    Do you think the error will be in my side or is it because  of actual company's working org link?

  • Suggested answer
    Bipin D365 Profile Picture
    28,995 Moderator on at

    Hi,

    Can you please create a trial instance and register your code in trial instance to check if it works?

    In Your actual instance, Check if you have any workflow/business rule/JS which is updating the job title field value.

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • Renny99 Profile Picture
    15 on at

    I have a similar issue where dynamics is timing out (that does show in the plugin logs). just an idea

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

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

#1
11manish Profile Picture

11manish 66 Super User 2026 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 46 Super User 2026 Season 2

#3
Subra Profile Picture

Subra 40 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans