How to use this in a web resource

Aug 14, 2012 at 10:28 PM

my project is to create a web resources that has related companies to the company entity

i try to use tool kit with fetch in the web resources to get the data from the crm 

but it keep telling me XrmServiceToolkit is undefined

i have a created a web resources which used the tool kit in the company form

below is the web resources 

Thanks for all the help

<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD>
<SCRIPT src="http://severname/organizationName/WebResources/tcp_XRMServiceToolkit.js"></SCRIPT>

<SCRIPT>
var LocationFetchXML = 
                "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+
                    "<entity name='tcp_location'>"+
                    "<attribute name='tcp_locationid' />"+
                    "<order attribute='tcp_name' descending='false' />"+
                    "<filter type='and'>"+
                      "<condition attribute='statecode' operator='eq' value='0' />"+
                    "</filter>"+
                  "</entity>"+
                "</fetch>";


            var retrievedLocations = XrmServiceToolkit.Soap.Fetch(LocationFetchXML);
   </SCRIPT>

<META charset=utf-8></HEAD>
<BODY contentEditable=true></BODY></HTML>

but i keep getting error like 

Aug 14, 2012 at 10:46 PM
Edited Aug 14, 2012 at 10:55 PM

I have make some changes but now i still get 

Error: Context is not available.

 

 

 

<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD>

<SCRIPT type=text/javascript src="tcp_XRMServiceToolkit.js"></SCRIPT>

<SCRIPT>
var LocationFetchXML = 
                "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+
                    "<entity name='tcp_location'>"+
                    "<attribute name='tcp_locationid' />"+
                    "<order attribute='tcp_name' descending='false' />"+
                    "<filter type='and'>"+
                      "<condition attribute='statecode' operator='eq' value='0' />"+
                    "</filter>"+
                  "</entity>"+
                "</fetch>";


            var retrievedLocations = window.XrmServiceToolkit.Soap.Fetch(LocationFetchXML);
   </SCRIPT>

<META charset=utf-8></HEAD>
<BODY contentEditable=true>
<SCRIPT type=text/javascript src="http://maps.gstatic.com/intl/en_us/mapfiles/api-3/9/13b/main.js"></SCRIPT>

<SCRIPT type=text/javascript src="http://maps.gstatic.com/intl/en_us/mapfiles/api-3/9/13b/main.js"></SCRIPT>

<SCRIPT type=text/javascript src="http://maps.gstatic.com/cat_js/intl/en_ALL/mapfiles/api-3/9/13b/%7Bmain,geometry%7D.js"></SCRIPT>
</BODY></HTML>
Coordinator
Aug 15, 2012 at 10:04 AM

Hi.

When using html as a web resource, you will need to get several reference for the XRM objects. The details could be find in CRM 2011 SDK.

Jaimie

<script type="text/javascript" src="ClientGlobalContext.js.aspx"></script>
<script type="text/javascript" src="tcp_json2"></script>
<script type="text/javascript" src="tcp_jquery"></script>
<script type="text/javascript" src="tcp_xrmservicetoolkit"></script>