Plug-in not triggering on the Custom Message created using Actions in CRM 2016

时间:2016-06-07 11:29:00

标签: javascript dynamics-crm dynamics-crm-2013 dynamics-crm-2015 dynamics-crm-2016

I've created a ribbon button, a blank action(process) and a Plug-in. I'm calling the action (JavaScript) from the ribbon button which further needs to trigger the plug-in using the custom message. I'm able to call the action using the soap call but it's not triggering the plug-in that has been registered on that custom message. I've put in an alert in the bottom of the helper method which is popping out successfully however the plug-in cannot be triggered. Any help is appreciated....

function SendIOButtonActionCall() {
var entityId = Xrm.Page.data.entity.getId();
var entityName = Xrm.Page.data.entity.getEntityName();
var requestName = "vm_SendIOButton";
var OpportunityId = String(Xrm.Page.data.entity.getId());
ExecuteAction(entityId, entityName, requestName);
//window.location.reload(true);   
}

function ExecuteAction(entityId, entityName, requestName) {
    // Creating the request XML for calling the Action
var requestXML = ""
requestXML += "<s:envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";
requestXML += "  <s:body>";
requestXML += "    <execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">";
requestXML += "      <request xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\">";
requestXML += "        <a:parameters xmlns:b=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">";
requestXML += "          <a:keyvaluepairofstringanytype>";
requestXML += "            <b:key>Target</b:key>";
requestXML += "            <b:value i:type=\"a:EntityReference\">";
requestXML += "              <a:id>" + entityId + "</a:id>";
requestXML += "              <a:logicalname>" + entityName + "</a:logicalname>";
requestXML += "              <a:name i:nil=\"true\">";
requestXML += "            </a:name></b:value>";
requestXML += "          </a:keyvaluepairofstringanytype>";
requestXML += "        </a:parameters>";
requestXML += "        <a:requestid i:nil=\"true\">";
requestXML += "        <a:requestname>" + requestName + "</a:requestname>";
requestXML += "      </a:requestid></request>";
requestXML += "    </execute>";
requestXML += "  </s:body>";
requestXML += "</s:envelope>";
var req = new XMLHttpRequest();
req.open("POST", GetClientUrl(), false)
req.setRequestHeader("Accept", "application/xml, text/xml, */*");
req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
req.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
req.send(requestXML); 
alert("success");
//Get the Response from the CRM Execute method
//var response = req.responseXML.xml;
}

function GetClientUrl() {
if (typeof Xrm.Page.context == "object") {
    clientUrl = Xrm.Page.context.getClientUrl();
}
var ServicePath = "/XRMServices/2011/Organization.svc/web";
return clientUrl + ServicePath;
} 

1 个答案:

答案 0 :(得分:3)

要检查的事项:

  1. 验证您的插件步骤已启用。
  2. 验证您的插件是否有效
    1. 在针对某个实体的更新等消息上注册您的插件步骤,看看是否可以触发它。
    2. 向插件添加日志记录以查看是否可以记录该内容
  3. 通过创建记录来验证您的操作。
  4. 使用Fiddler检查按钮生成的任何流量中是否有任何错误返回。