CRM 4.0 - 创建方法克隆报价记录

时间:2014-11-05 09:31:05

标签: javascript crm dynamics-crm-4

有人可以帮我吗?

我尝试通过javascript使用create方法创建记录。 我需要复制所有字段'价值并创造一个新的实体。就像克隆CRM 4.0中的记录一样

我使用报价实体。我试图通过机会。它很成功但是当我查看网格视图时,机会字段是空白的。但在形式上,它有一个价值。

然后我尝试查看机会表格并查看相关的报价,但它并没有出现在那里。

感谢您的回复。这是我的代码



>    	
	var authenticationHeader = GenerateAuthenticationHeader();
	var OpportunityID = crmForm.all.opportunityid.DataValue[0].id;		
	var varFields = "<opportunityid>"+ OpportunityID +"</opportunityid>"

	var xml = "<?xml version='1.0' encoding='utf-8'?>" + 
	"<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'>"+ 
	authenticationHeader+
	"<soap:Body>"+ 
	"<Create xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+ 
	"<entity xsi:type='quote'>"+ 
	varFields +	
	"</entity>"+ 
	"</Create>"+ 
	"</soap:Body>"+ 
	"</soap:Envelope>";
	// Prepare the xmlHttpObject and send the request.
	var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
	xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
	xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Create");
	xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
	xHReq.setRequestHeader("Content-Length", xml.length);
	xHReq.send(xml);
	// Capture the result
	var resultXml = xHReq.responseXML;

	// Check for errors.
	var errorCount = resultXml.selectNodes('//error').length;
	if (errorCount != 0)
	{
	 var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
	 alert(msg);
	}
	// Open new contact record if no errors.
	else
	{
	   var quoteid = resultXml.selectSingleNode("//CreateResult");
	   window.open("/sfa/quotes/edit.aspx?id={"+quoteid.nodeTypedValue+"}");
	}
}
	
&#13;
&#13;
&#13;

请帮助我。 我真的非常需要它。

非常感谢你。

0 个答案:

没有答案