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:
var xml = "" + "<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>" + ""; var xmlHttpRequest = new XMLHttpRequest(); xmlHttpRequest.open("POST", Xrm.Page.context.getClientUrl() +"/XRMServices/2011/Organization.svc/web", false); xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/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);
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..
Advertisements
Hi Nishant,
Created action & calling that action using c# plugin code, but no error is getting unable to do .
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
Reblogged this on CRM Practice.
LikeLike
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