ttajic
11/11/2016 - 9:24 AM

InstantiateTemplateRequest

InstantiateTemplateRequest

adacta.email.InstantiateTemplateRequest = function (templateId, objectType, objectId) {
    var request = 
    	["<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 i:type='b:InstantiateTemplateRequest' xmlns:a='http://schemas.microsoft.com/xrm/2011/Contracts xmlns:b='http://schemas.microsoft.com/crm/2011/Contracts'>",
		"<a:Parameters xmlns:c='http://schemas.datacontract.org/2004/07/System.Collections.Generic'>",
		"<a:KeyValuePairOfstringanyType>",
		"<c:key>TemplateId</c:key>",
		"<c:value i:type='d:guid' xmlns:d='http://schemas.microsoft.com/2003/10/Serialization/'>" + templateID + "</c:value>",
		"</a:KeyValuePairOfstringanyType>",
		"<a:KeyValuePairOfstringanyType>",
		" <c:key>ObjectType</c:key>",
		"          <c:value i:type='d:string' xmlns:d='http://www.w3.org/2001/XMLSchema'>" + objectType + "</c:value>",
		"       </a:KeyValuePairOfstringanyType>",
		"      <a:KeyValuePairOfstringanyType>",
		"       <c:key>ObjectId</c:key>",
		"      <c:value i:type='d:guid' xmlns:d='http://schemas.microsoft.com/2003/10/Serialization/'>" + objectId + "</c:value>",
		"   </a:KeyValuePairOfstringanyType>",
		"</a:Parameters>",
		"<a:RequestId i:nil='true' />",
		"<a:RequestName>InstantiateTemplate</a:RequestName>",
		"</request>",
		"</Execute>",
		"</s:Body>",
		"</s:Envelope>"].join("");

	var result = XrmServiceToolkit.Soap.Execute(request, null);
	return result;
};