Hi,
We recently had a requirement to call Plugin on execute of an Action.
To implement this,
We created a blank Action named Trigger Plugin for custom entity named Security Entity.
Open Plugin Registration Tool and connect to the Org and we will have our action available there as message for our Plugin Step
We can execute our Action from C# and Jscript which in turns will call our Plugin.
C# Code:
Jscript Code:
</p> <p>var xml = "" +<br /> "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body><Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><request xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\"><a:Parameters xmlns:b=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\"><a:KeyValuePairOfstringanyType><b:key>Target</b:key><b:value i:type=\"a:EntityReference\"><a:Id>1c54dadd-f91b-e511-a5ca-c4346bacae20</a:Id><a:LogicalName>tk_securityentity</a:LogicalName><a:Name i:nil=\"true\"/></b:value></a:KeyValuePairOfstringanyType></a:Parameters><a:RequestId i:nil=\"true\"/><a:RequestName>new_TriggerPlugin</a:RequestName></request></Execute></s:Body></s:Envelope>" +<br /> "";</p> <p>var xmlHttpRequest = new XMLHttpRequest();</p> <p>xmlHttpRequest.open("POST", Xrm.Page.context.getClientUrl() +"/XRMServices/2011/Organization.svc/web", false);<br /> xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");<br /> xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");<br /> xmlHttpRequest.setRequestHeader("Accept", "application/xml, text/xml, */*");<br /> xmlHttpRequest.setRequestHeader("Content-Length", xml.length);<br /> xmlHttpRequest.send(xml);</p> <p>var resultXml = xmlHttpRequest.responseText;<br /> alert(resultXml);</p> <p>
Use the SoapLogger tool to get the Soap request
https://nishantrana.me/2014/08/27/updated-soaplogger-for-crm-2013-to-generate-javascript/
Hope it helps..
HTTP RESPONSE
————————————————–
http://www.w3.org/2003/05/soap-envelope:Sender
you are mickey mouse
-2147220891
OperationStatus
0
SubErrorCode
-2146233088
This is custom error message
2015-07-04T04:40:02.459002Z
[testPlugin: testPlugin.Class1]
[489d435e-bc21-e511-8c30-c4346bacae20: testPlugin.Class1: new_TriggerPlugin of tk_securityentity]
LikeLike
Reblogged this on CRM Practice.
LikeLike
Hi Rana , I Need to get action parameters data In plugin. I hv 5 input parameters i need to get those parameters daa in plugin…
Please sens me the codeb
LikeLike
Hi Nishant,
Created action & calling that action using c# plugin code, but no error is getting unable to do .
LikeLike
Hi Nishant, I am new to CRM development and thanks for this post. how ever, where did you put the C# and JavaScript codes? How these C# and JavaScript component are integrated with CRM?
LikeLike
C# code you can use within a console app and JavaScript within Ribbon Button in most cases.
LikeLike