CRM 2011 Javascript Fetch XML synchronous or asynchronous call
Using helper function to execute FetchXML request is great.
The code below is retrieved from this blog, and all I had to do is to add extra logic when parsing the XML result because I want to grab the attributes from the related entity as well.
Modified FetchUtil.js:
To use it you just need to do it like this (synchronous)
If it's asynchronous the last bit will be:
The parsed result object can be queried like this:
Hope this helps,
Andreas
The code below is retrieved from this blog, and all I had to do is to add extra logic when parsing the XML result because I want to grab the attributes from the related entity as well.
Modified FetchUtil.js:
To use it you just need to do it like this (synchronous)
If it's asynchronous the last bit will be:
The parsed result object can be queried like this:
Hope this helps,
Andreas
Hi...
ReplyDeleteThanks a lot for share your knowledge with us. Okay, while this method does enable you to execute a FetchXML request in JavaScript against the 2011 SOAP endpoint, it doesn't return XML in the same format as the 4.0 web service did.
Keep sharing.
hey it works on me but when i try to save the form it gives an error message:
ReplyDelete“An Error has occurred. Try this action again. If the problem continues, check the Microosft Dynamics CRM Community for solutions or contact your Microsoft Dynamics administrator. Finally, you can contact Microsoft Support.”
can u help me?
Hi Ahmet, what happens after you click ok to that message?
ReplyDeleteI believe that error message is not related to this as it doesn't look like a JS error.
I got error at request += CrmEncodeDecode.CrmXmlEncode(sFetchXml); this line
ReplyDeleteCrmEncodeDecode is not defined
Hi m2012,
DeleteAre you running this outside CRM?
You might want to check this out:
http://mscrmkb.blogspot.com.au/2011/12/crm-2011-javascript-giving-error.html
Andreas
ReplyDeleteWhere did you get the information for the a:AliasedValue from - the code is failing for me as all that seems to be there is the name which is in attr.childNodes[k].childNodes[1].childNodes[2].childNodes[0].text; and the other childnodes are not there (e.g. attr.childNodes[k].childNodes[1].childNodes[2].childNodes[1].text;) making the code fail?
I am reading the parent account name from the contact
Andrew
Hi,
DeleteSorry I can't remember what I used AliasedValue for - but I needed it that's why I put it there I believe. If you don't need those attributes feel free to remove it to make it work on your end :D
Hi
ReplyDeleteThanks for sharing. I'm getting "Access is deined" error. Can some one guide me how to avoid this.
Are you a system administrator? it might be entity permission issue.
Delete