Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Error while calling plugin from Javascript

(0) ShareShare
ReportReport
Posted on by 6,211

Hi All, 

I am calling Plugin from JavaScript using Action, CRM version(9.0.2.449) also i am using CrmSdk.CoreAssemblies version 9.0.2.3.

Below is the error detail,

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Unexpected exception from plug-in (Execute): Clone.CloneOpportunity: System.NullReferenceException: Object reference not set to an instance of an object.Detail:
<OrganizationServiceFault xmlns:i="www.w3.org/.../XMLSchema-instance" xmlns="schemas.microsoft.com/.../Contracts">
<ActivityId>168d9982-8c44-4b9d-87c3-66ba64225363</ActivityId>
<ErrorCode>-2147220956</ErrorCode>
<ErrorDetails xmlns:d2p1="schemas.datacontract.org/.../System.Collections.Generic" />
<Message>Unexpected exception from plug-in (Execute): Clone.CloneOpportunity: System.NullReferenceException: Object reference not set to an instance of an object.</Message>
<Timestamp>2018-06-28T11:36:29.8297083Z</Timestamp>
<ExceptionRetriable>false</ExceptionRetriable>
<ExceptionSource>PluginExecution</ExceptionSource>
<InnerFault i:nil="true" />
<OriginalException>System.NullReferenceException
at Clone.CloneOpportunity.Execute(IServiceProvider serviceProvider)
at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.&lt;&gt;c__DisplayClass14_3.&lt;Execute&gt;b__0()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, Dictionary`2 sandboxServices, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, IPluginExecutionContext requestContext, Boolean enablePluginStackTrace, Boolean chaosFailAppDomain)
at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, Dictionary`2 sandboxServices, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, IPluginExecutionContext requestContext, Boolean enablePluginStackTrace, Boolean chaosFailAppDomain)
at Microsoft.Crm.Sandbox.SandboxWorker.Execute(SandboxCallInfo callInfo, SandboxPluginExecutionContext requestContext, Guid pluginAssemblyId, Int32 sourceHash, String assemblyName, Guid pluginTypeId, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, SandboxRequestCounter&amp; workerCounter, Boolean returnTraceInfo)</OriginalException>
<TraceText i:nil="true" />
</OrganizationServiceFault>

Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.Crm.Sandbox.ISandboxHost.ExecuteAndReturnTraceInfo(SandboxCallInfo callInfo, SandboxPluginExecutionContext requestContext, Guid pluginAssemblyId, Int32 sourceHash, String assemblyName, Guid pluginTypeId, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, String assemblyContents, Boolean returnTraceInfo)
at Microsoft.Crm.Sandbox.SandboxPlugin.Execute(SandboxClient client, SandboxCallTracker callTracker, IExecutionContext requestContext, String assemblyContents, Boolean returnTraceInfo)
at Microsoft.Crm.Sandbox.SandboxCodeUnit.ExecuteInternal(SandboxClient client, IExecutionContext context, SandboxTraceContext sandboxTraceContext, SandboxCallTracker callTracker, Guid parentExecutionId, String assemblyContents, Boolean& isSafeToRetry, Boolean& executeDone)
at Microsoft.Crm.Sandbox.SandboxCodeUnit.<>c__DisplayClass24_0.<Execute>b__0()

Best Regards,

Shahbaaz

*This post is locked for comments

  • Shahbaaz Ansari Profile Picture
    6,211 on at
    RE: Error while calling plugin from Javascript

    hahaha..that was really very silly from me.

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Error while calling plugin from Javascript

    Hello,

    Replace line

    ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(IServiceProvider));

    with line

    ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));

  • Shahbaaz Ansari Profile Picture
    6,211 on at
    RE: Error while calling plugin from Javascript

    Thanks Mahender for the reply, Below is my code, i am just tracing the log.

    Code :

    using Microsoft.Xrm.Sdk;
    using System;
    
    namespace Clone
    {
       public class CloneOpportunity : IPlugin
       {
           public void Execute(IServiceProvider serviceProvider)
    
           {
               //Extract the tracing service for use in debugging sandboxed plug-ins.
    
               ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(IServiceProvider));
    
               tracingService.Trace("called from javascript");
           }
       }
    }

    Regards,

    Shahbaaz

  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at
    RE: Error while calling plugin from Javascript

    Hello,

    I will suggest you to debug your plugin and see where it's failing or you can try same login in console app first and when working fine can use it 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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
dkrishna Profile Picture

dkrishna 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans