Answered by:
many fetch xml in the same java script

Question
-
Hi all,
I need to perform many fetch xml queries in the same java script of the onLoad event
so i try to copy/paste the same code and only to modify the query itself
but unfortunately the second query always didn't work
could anybody please advise on what else must be modified so both queries run succesfully:
noting that i'm using the following code in copy/paste:
var authenticationHeader = window.opener.GenerateAuthenticationHeader();
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>" +
"<RetrieveMultiple xmlns="+
"\"http://schemas.microsoft.com/crm/2007/WebServices\">" +
"<query xmlns:q1="+
"\"http://schemas.microsoft.com/crm/2006/Query\" "+
"xsi:type=\"q1:QueryByAttribute\">" +
"<q1:EntityName>contact</q1:EntityName>" +
"<q1:ColumnSet xsi:type=\"q1:ColumnSet\">" +
"<q1:Attributes>" +
"<q1:Attribute>parentcustomerid</q1:Attribute>" +
"</q1:Attributes>" +
"</q1:ColumnSet>" +
"<q1:Attributes>" +
"<q1:Attribute>support_managerid</q1:Attribute>" +
"</q1:Attributes>" +
"<q1:Values>" +
"<q1:Value xsi:type=\"xsd:string\">"+
loggedUserID+
"</q1:Value>" +
"</q1:Values>" +
"</query>" +
"</RetrieveMultiple>" +
"</soap:Body>" +
"</soap:Envelope>";
var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
xmlHttpRequest.Open("POST","/mscrmservices/2007/CrmService.asmx",false);
xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
xmlHttpRequest.send(xml);
var resultXml = xmlHttpRequest.responseXML.xml;
var doc = new ActiveXObject("MSXML2.DOMDocument");
doc.async = false;
doc.loadXML(resultXml);
var parentCustomerId = doc.selectSingleNode("//q1:parentcustomerid");
if( parentCustomerId != null )
{
alert(parentCustomerId.text);
}
else
{
return null;
}
any help will be appreciated,
thanks in advance :)
Tuesday, October 5, 2010 1:04 PM
Answers
-
may be the variables conflict.
just append 1 to all the variable you are using in the 2nd fetchxml call.
yes.sudhanshu
http://bproud2banindian.blogspot.com
http://ms-crm-2011-beta.blogspot.com- Marked as answer by Donna EdwardsMVP Thursday, October 14, 2010 1:39 PM
Friday, October 8, 2010 12:15 PM
All replies
-
Tuesday, October 5, 2010 1:09 PMAnswerer
-
I didn't get any errors
it just didn't display the results
Tuesday, October 5, 2010 1:33 PM -
may be the variables conflict.
just append 1 to all the variable you are using in the 2nd fetchxml call.
yes.sudhanshu
http://bproud2banindian.blogspot.com
http://ms-crm-2011-beta.blogspot.com- Marked as answer by Donna EdwardsMVP Thursday, October 14, 2010 1:39 PM
Friday, October 8, 2010 12:15 PM