Skip to main content

Notifications

Dynamics 365 Community / Forums / Sales forum / Saving of the Contact ...
Sales forum
Answered

Saving of the Contact form throws ISV error

Posted on by 15
Hi
 
I'm new to the Dynamics environment & started to learn the development, I tried to create a save the contact by providing the required details on click on SAVE button throws ISV error . Could you please help me in resolving this issue
 
Exception Message: The method or operation is not implemented.
ErrorCode: -2147220956
HexErrorCode: 0x80040224
HelpLink: http://go.microsoft.com/fwlink/?LinkID=398563&error=Microsoft.Crm.CrmException%3a80040224&client=platform
TraceText: 
    [TestD365: FirstPlugin.HelloWorld]
    [76f8cb80-620d-ef11-9f89-0022486e22c5: FirstPlugin.HelloWorld: Create of contact]
Activity Id: d8a51563-4a10-4555-9d29-28edefe85c5c
 
 
Here is the source code
 
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xrm.Sdk;
using System.ServiceModel;
namespace MyPlugins
{
    public class HelloWorld : IPlugin
    {
        public void Execute(IServiceProvider serviceProvider)
        {
            // Extract the tracing service for use in debugging sandboxed plug-ins.  
            // If you are not registering the plug-in in the sandbox, then you do  
            // not have to add any tracing service related code.  
            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
                        {
                    // TODO Plug-in business logic goes here. You can access data in the context,
                    // and make calls to the Organization web service using the Dataverse SDK.
                    string firstName = string.Empty;
                   
                    if(entity.Attributes.Contains(/firstname/))
                    {
                         firstName = entity.Attributes[/firstname/].ToString();
                    }
                    string lastName = entity.Attributes[/lastname/].ToString();
       entity.Attributes.Add(/description/, /Hello world / + firstName + / / + lastName);
        
                }
                catch (FaultException<OrganizationServiceFault> ex)
                {
                    throw new InvalidPluginExecutionException(/An error occurred in MyPlug-in./, ex);
                }
                catch (Exception ex)
                {
                    tracingService.Trace(/MyPlugin: {0}/, ex.ToString());
                    throw;
                }
            }
        }
    }
}
 
 
 
 
 
 
 
 
 
 
Thanks
 
 
 
Categories:
  • CU09051530-0 Profile Picture
    CU09051530-0 15 on at
    Saving of the Contact form throws ISV error
    Thank you for the quick reply :) @vinit
  • Verified answer
    Vinit_Bhagat Profile Picture
    Vinit_Bhagat 113 on at
    Saving of the Contact form throws ISV error
    Hi,
     
    I tried your Source code at my end and it is working fine.
     
    Below are the details and source code:
    1. Plugin Stage - Pre-operation
    2. Execution Mode -  Synchronous
    3. Filtering attributes - firstname, lastname
     
     
     
     
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.ServiceModel;
    using System.Text;
    using System.Threading.Tasks;
    using Microsoft.Xrm.Sdk;
    namespace CRM.Plugins
    {
        public class UpdateContact : IPlugin
        {
            public void Execute(IServiceProvider serviceProvider)
            {
                // Extract the tracing service for use in debugging sandboxed plug-ins.  
                // If you are not registering the plug-in in the sandbox, then you do  
                // not have to add any tracing service related code.  
                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
                    {
                        // TODO Plug-in business logic goes here. You can access data in the context,
                        // and make calls to the Organization web service using the Dataverse SDK.
                        string firstName = string.Empty;
                        if (entity.Attributes.Contains("firstname"))
                        {
                            firstName = entity.Attributes["firstname"].ToString();
                        }
                        string lastName = entity.Attributes["lastname"].ToString();
                        entity.Attributes.Add("description", "Hello world " + firstName + " " +lastName);
                    }
                    catch (FaultException<OrganizationServiceFault> ex)
                    {
                        throw new InvalidPluginExecutionException("An error occurred in MyPlug -in.", ex);
                    }
                    catch (Exception ex)
                    {
                        tracingService.Trace("MyPlugin: {0}", ex.ToString());
                        throw;
                    }
                }
            }
        }
    }

    I hope you can mark my answer verified if it answer your question! If you have any questions, please feel free to contact me.
    ​​​​​​​
    Thanks, 
    VB
     
  • Suggested answer
    Vinit_Bhagat Profile Picture
    Vinit_Bhagat 113 on at
    Saving of the Contact form throws ISV error
    Hello,
     
    It seems that you have a plugin registered on create of Contact record which throwing an error. If you disable the plugin, you will be able to save the record.
     
    To check more about this error, will require source code.
     
    Thanks,
    VB
  • Suggested answer
    Guido Preite Profile Picture
    Guido Preite 54,003 Super User on at
    Saving of the Contact form throws ISV error
    Hi,
    the error is telling you that a plugin called "FirstPlugin.HelloWorld" is registered to the Create event of a contact, if you see the error it means the plugin is synchronous.
    Or you disable the plugin or you update the plugin to resolve the error, without the source code of the plugin is not possible to provide further help.

Helpful resources

Quick Links

Take the Community feedback survey!

Answer this brief 15-question survey about your Community experience…

Demystifying Copilot: Service Edition with Sundar Raghavan

Sundar answers more questions about Copilot for Service...

Dynamics 365 Business Central vs Finance and SCM

Take a look at the key differences between Business Central and…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,377 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 223,308 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,140

Featured topics

Product updates

Dynamics 365 release plans