Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Call plugin using Ribbon Button in Dynamic CRM

Posted on by Microsoft Employee

Hi all,
I want to call plugin using custom ribbon button in Dynamic CRM online(Dynamic 365).
I have go though several link but still i am getting error.
My Code is

function CallActionFromJavaScript() {
debugger;
var entityId = Xrm.Page.data.entity.getId();
var entityName = "new_customsendactivity";
var requestName = "new_ActionCall";

var xml = "" +
"<s:Envelope xmlns:s=\"schemas.xmlsoap.org/.../envelope\"><s:Body><Execute xmlns=\"schemas.microsoft.com/.../Services\" xmlns:i=\"www.w3.org/.../XMLSchema-instance\"><request xmlns:a=\"schemas.microsoft.com/.../Contracts\"><a:Parameters xmlns:b=\"schemas.datacontract.org/.../System.Collections.Generic\"><a:KeyValuePairOfstringanyType><b:key>Target</b:key><b:value i:type=\"a:EntityReference\"><a:Id>"+entityId+"</a:Id><a:LogicalName>"+entityName+"</a:LogicalName><a:Name i:nil=\"true\"/></b:value></a:KeyValuePairOfstringanyType></a:Parameters><a:RequestId i:nil=\"true\"/><a:RequestName>"+requestName+"</a:RequestName></request></Execute></s:Body></s:Envelope>" +
"";

var xmlHttpRequest = new XMLHttpRequest();

xmlHttpRequest.open("POST", "cenacis.crm8.dynamics.com/.../web", true);
xmlHttpRequest.setRequestHeader("SOAPAction","schemas.microsoft.com/.../Execute");
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.setRequestHeader("Accept", "application/xml, text/xml, */*");
//xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
xmlHttpRequest.send(xml);

var resultXml = xmlHttpRequest.responseText;
alert(resultXml);
}


Below is my Plugin steps
4667.Untitled12.png

And below is the plugin Code

pluginda.png

I am getting the below error when call from button
5734.error.png

Please suggest, how to resolve this issue.

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Call plugin using Ribbon Button in Dynamic CRM

    Thanks all for sharing links and views.

    I have solved my problem. Issue is inside the code, in the line

    "Entity entity = (Entity)context.InputParameters["Target"]; "

    As in .js file i have taken EntityRefrence as target and in the code i have written "Entity as Target"

    After changing

    Entity entity = (Entity)context.InputParameters["Target"];

    to

                  EntityReference refrence = (EntityReference)context.InputParameters["Target"];

    it works.

    :)

  • Suggested answer
    Alagunellaikumar Profile Picture
    Alagunellaikumar 6,210 on at
    RE: Call plugin using Ribbon Button in Dynamic CRM

    Hi John,

    Please refer the below URL

    debajmecrm.com/.../invoke-your-custom-action-from-dynamics-crm-web-apidynamics-crm-2016

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Call plugin using Ribbon Button in Dynamic CRM

    Hi Shidin Haridas 

    below is the screenshot of response header

    4555.Screenshot_5F00_4.png

    and below is the response 
    "

    <s:Envelope xmlns:s="schemas.xmlsoap.org/.../envelope"><s:Body><s:Fault><faultcode>s:Client</faultcode><faultstring xml:lang="en-US">Process action associated with this process is not activated.</faultstring><detail><OrganizationServiceFault xmlns="schemas.microsoft.com/.../Contracts" xmlns:i="www.w3.org/.../XMLSchema-instance"><ActivityId>f96bb96e-415d-46b9-85d9-5db26eb71c50</ActivityId><ErrorCode>-2147220891</ErrorCode><ErrorDetails xmlns:a="schemas.datacontract.org/.../System.Collections.Generic"><KeyValuePairOfstringanyType><a:key>OperationStatus</a:key><a:value i:type="b:int" xmlns:b="www.w3.org/.../XMLSchema">0</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>SubErrorCode</a:key><a:value i:type="b:int" xmlns:b="www.w3.org/.../XMLSchema">-2146233088</a:value></KeyValuePairOfstringanyType></ErrorDetails><Message>Process action associated with this process is not activated.</Message><Timestamp>2017-02-23T10:37:28.454577Z</Timestamp><ExceptionSource>PluginExecution</ExceptionSource><InnerFault i:nil="true"/><OriginalException>Microsoft.Xrm.Sdk.InvalidPluginExecutionException&#xD;
    at ActionCall.ActionCallclass.Execute(IServiceProvider serviceProvider)&#xD;
    at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.&lt;&gt;c__DisplayClass7.&lt;Execute&gt;b__0()&#xD;
    --- End of stack trace from previous location where exception was thrown ---&#xD;
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#xD;
    at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, Dictionary`2 sandboxServices, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, IPluginExecutionContext requestContext)&#xD;
    at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, Dictionary`2 sandboxServices, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, IPluginExecutionContext requestContext)&#xD;
    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>&#xD;
    [ActionCall: ActionCall.ActionCallclass]&#xD;
    [401b701a-a0f2-e611-810c-c4346bdd8041: ActionCall.ActionCallclass: Create of account]&#xD;
    &#xD;
    </TraceText></OrganizationServiceFault></detail></s:Fault></s:Body></s:Envelope>

    "

  • Shidin Haridas Profile Picture
    Shidin Haridas 3,497 on at
    RE: Call plugin using Ribbon Button in Dynamic CRM

    Hi John Cather ,

    Assuming the following:

    1. You do not want to use any of the workarounds suggested by Rich Pearson Scott Durow (MVP) 

    2. You have made the message name changes in the Plugin and the JScript code, can you do the following?

    Using the 'Network' tab under the Developer Tools on the browser, can you post a screenshot of the 'Response Headers'?

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Call plugin using Ribbon Button in Dynamic CRM

    I think you are missing some code in Plugin.Refer this:

    nishantrana.me/.../using-action-to-trigger-plugin-in-crm-20132015

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Call plugin using Ribbon Button in Dynamic CRM

    Scott Durow

    I am getting error while calling the action, please see my question on top.

    I have share the details

  • ScottDurow Profile Picture
    ScottDurow 50,177 on at
    RE: Call plugin using Ribbon Button in Dynamic CRM

    An Action is essentially an on demand sync Workflow - both can trigger plugins or call custom workflow activities.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Call plugin using Ribbon Button in Dynamic CRM

    @Scott Drow,

    i want to call plugin from Action on button click not workflow

  • ScottDurow Profile Picture
    ScottDurow 50,177 on at
    RE: Call plugin using Ribbon Button in Dynamic CRM

    If you create a realtime workflow - you can call the action from the workflow - then use the Ribbon Workbench Smart buttons to call that workflow.

    See - www.develop1.net/.../Smart-Buttons-in-the-Ribbon-Workbench.aspx

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Call plugin using Ribbon Button in Dynamic CRM

    Is your action Active on your CRM organisation. Try to activate and then try again.

    Please try to call your action directly using a plugin first. This will help in eliminating if the issue is in action and plugin or xml call. Refer this:

    https://mahenderpal.wordpress.com/2015/07/08/using-actions-in-microsoft-dynamics-crm-2015/

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans