Dynamics crm 从功能区按钮运行工作流
我试图从网格中的功能区按钮运行工作流:Dynamics crm 从功能区按钮运行工作流,dynamics-crm,crm,dynamics-crm-2013,Dynamics Crm,Crm,Dynamics Crm 2013,我试图从网格中的功能区按钮运行工作流: function TriggerWorkflow(entityId, workflowGuid) { debugger; /*Generate Soap Body.*/ var soapBody = "<soap:Body>" + " <Execute xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"
function TriggerWorkflow(entityId, workflowGuid)
{
debugger;
/*Generate Soap Body.*/
var soapBody = "<soap:Body>" +
" <Execute xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>" +
" <Request xsi:type=\'ExecuteWorkflowRequest\'>" +
" <EntityId>" + entityId + "</EntityId>" +
" <WorkflowId>" + workflowGuid + "</WorkflowId>" +
" </Request>" +
" </Execute>" +
"</soap:Body>";
/*Wrap the Soap Body in a soap:Envelope.*/
var soapXml = "<soap:Envelope " +
" xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' " +
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " +
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" +
GenerateAuthenticationHeader() +
soapBody +
"</soap:Envelope>";
/* Create the XMLHTTP object for the execute method.*/
var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlhttp.open("POST", "/MSCRMservices/2007/crmservice.asmx", false);
xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlhttp.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Execute");
/* Send the XMLHTTP object. */
xmlhttp.send(soapXml);
}
函数触发器工作流(entityId,workflowGuid)
{
调试器;
/*生成Soap主体*/
var soapBody=“”+
" " +
" " +
“”+entityId+“”+
“”+workflowGuid+“”+
" " +
" " +
"";
/*用肥皂:信封包裹肥皂主体*/
var soapXml=“”+
GenerateAuthenticationHeader()+
皂体+
"";
/*为execute方法创建XMLHTTP对象*/
var xmlhttp=newActiveXObject(“Msxml2.xmlhttp”);
open(“POST”,“/MSCRMservices/2007/crmservice.asmx”,false);
setRequestHeader(“内容类型”,“text/xml;charset=utf-8”);
setRequestHeader(“SOAPAction”http://schemas.microsoft.com/crm/2007/WebServices/Execute");
/*发送XMLHTTP对象*/
send(soapXml);
}
但它确实抛出了一个例外:
GenerateAuthenticationHeader()
未定义请尝试使用以下代码,而不是使用GenerateAuthenticationHeader()
:
var context = GetGlobalContext();
var header = context.getAuthenticationHeader();
或者,如果它不起作用,则手动创建身份验证标头
<soap:Header>
<CrmAuthenticationToken xmlns="http://schemas.microsoft.com/crm/2007/WebServices">
<AuthenticationType xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">
0
</AuthenticationType>
<OrganizationName xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">
AdventureWorksCycle
</OrganizationName>
<CallerId xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">
00000000-0000-0000-0000-000000000000
</CallerId>
</CrmAuthenticationToken>
</soap:Header>
0
冒险工作循环
00000000-0000-0000-0000-000000000000
错误消息似乎很明显:您是否验证函数GenerateAuthenticationHeader
是否在功能区按钮脚本的上下文中定义?如果将脚本包括到实体表单中,则此操作将不起作用,因为这些表单脚本是独立于功能区加载的。