FetchXml

I want to use FetchXml to retrieve account name from entity account. This is 
a very basic requirement that would build up to more advanced one. However i 
am getting a blank result after the below code is passed in an 'on change' 
event of a form.

Note I have CRM 4.0 however when i used web service 2007, it prompts me for 
a username and password , that's why i used 2006 WS. 

var xml = "";
xml += "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
xml += "<soap:Envelope 
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"";
xml += " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"";
xml += " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">";
xml += "<soap:Body>";
xml += "<fetchXml 
xmlns=\"http://schemas.microsoft.com/crm/2006/WebServices\">";
xml += "<fetch mapping='logical'><entity name='account'>";
xml += "<attribute name='name'/></entity></fetch></fetchXml>";
xml += "</soap:Body></soap:Envelope>";
alert(xml);
var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");

xmlHttpRequest.Open("POST", "/mscrmservices/2006/CrmService.asmx", false);
xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2006/WebServices/Fetch");
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
xmlHttpRequest.send(xml);

var resultXml = xmlHttpRequest.responseXML;
alert(resultXml.xml);

When I changed  Fetch to Retrieve in the following line:

xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2006/WebServices/Fetch");

I get a soap error message with code 0X80040203.

-- 
Cheers..
0
Malen (1)
5/26/2009 10:49:01 AM
crm 35858 articles. 1 followers. Follow

0 Replies
418 Views

Similar Articles

[PageSpeed] 42

Reply:

Similar Artilces:

fetching using fetchxml from Javascript problem
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\">" + "<soap:Body>" + "<fetchXml xmlns=\"http://schemas.microsoft.com/crm/2006/WebServices\">" + "<fetch mapping='logical'>" + "<entity name='inv...

FetchXml
I want to use FetchXml to retrieve account name from entity account. This is a very basic requirement that would build up to more advanced one. However i am getting a blank result after the below code is passed in an 'on change' event of a form. Note I have CRM 4.0 however when i used web service 2007, it prompts me for a username and password , that's why i used 2006 WS. var xml = ""; xml += "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"; xml += "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\...

fetchxml to dataset vb.net
I have the following code which makes a fetchxml query and actually does return all of the data I want: Dim service As New CrmService() service.Credentials =3D System.Net.CredentialCache.DefaultCredentials Dim fetch1 As String =3D _ "<fetch mapping=3D'logical'>" + _ "<entity name=3D'salesorderdetail'>" + _ "<all-attributes/>" + _ "</entity>" + _ "</fetch>" Dim result1 As String =3D service.Fetch(fetch1) Response....

Issue with FetchXML
Guys, I get the following error when trying to run the fetchxml code sample below: "80040e14 The correlation name 'opportunityopportunityid' is specified multiple times in a FROM clause." If I only include Part A it is fine, same if I only include Part B. Would someone please tell me that my fetchXML is wrong (I am relatively new at fetchXML), otherwise I have to infer that I cannot retrieve data using fetchXML from 2 entities that are related to the main entity using 2 mapping tables that use the same foreign key, this seems unlikely. I simply want to return...

FetchXML Parse
Hi, I have seen a tool created by James Downey called FetchXML that allows you to use a GUI to build FetchXML. It's great, nice work James! Has anyone experimented with the reverse? Suppose I want to take the FetchXML and translate it down to a TSQL statement. I've started experimenting already..loading the FetchXML into an XMLDocument in .NET and parsing through it to build a SQL string. Getting closer and can post my code once I've finished. Just curious if anyone has done this before. Thanks! -Shecky There are tool availabel on www.stunnware.com/crm2 -- Regards, MS ...

FetchXML IN Operator?
Anyone successfully used the IN operator in a fetch xml query? The syntax seems vague in the sdk docs, and there's no example of this, of course. Why are the examples always to demonstrate stuff like "select * from table" ? :) As best as I can tell, the syntax should look something like one of these, but I haven't stumbled across anything workable... <condition attribute = 'fieldname' operator='in' value='<value>a</value><value>b</value>' /> <condition attribute = 'fieldname' operator='in' &l...

FetchXML help!
I am trying to fetch all records which match certain criteria, and am having a problem when the attribute name I am looking for exists in both the root entity and the link-entity. Example: Fetch all opportunities where the opportunity name starts with "Test" OR the account name starts with "Test". This will find all opportunities whose account name starts with "Test" <fetch mapping='logical'> <entity name='opportunity'><all-attributes/> <link-entity name='account' to='customerid'> <fil...

FetchXml to SQL Query
I'm looking for a tool that converts FetchXml to equivelent SQL Query. Can you help? Not aware of anything that does this. If you are fairly handy with XML though it shouldn't be that difficult to write. -- Matt Parks MVP - Microsoft CRM "CRM Chief" <CRMChief@discussions.microsoft.com> wrote in message news:600AB470-BCA8-48F9-9CD8-652835945661@microsoft.com... I'm looking for a tool that converts FetchXml to equivelent SQL Query. Can you help? ...

FetchXml
Hi All, I tried to use Fetch(fetchXml) method to get some data back from account The returned result is not compatible UTF-8 or 16. Example: In the follwing example The name field contains special characters such as "&". Is it a Bug? <resultset> <result> <name>monthly & daily</name> </result> </resultset> Any Ideas? ...

FetchXML schema
Hi, I am trying to establish whether there is any way of using the Query object to return only a certain number of records from the CRM db. I have a a very simple app that either prompts a user for query conditions, or alternatively returns all objects from the specified entity (account/contact etc). The problem is that the db has upwards of 25,000 contacts, and the result set is huge. I cannot find anything in the FetchXML schema that suggests I can specifiy a number of records to return. If anyone can help me that would be great. Cheers Chris Hi Chris I havnt found a way to restric...