altun8tr
altun8tr

Reputation: 21

Crm 2015 Javascript Context is not defined from fetchxml

I want to get values from fetchxml using javascript in html web resource.I use crm 2015. The code block is in the attachment on picture.

After the fetchxml, I try to get values with soap function. it gives me the error

Error: Contex is not available

I added the xrmservicetoolkit for crm 2015 and jquery and json files. What is the problem? How can I solve this? Can anyone help me please?

var fetch = "<fetch version='1.0' mapping='logical'><entity name='quote'>";
  fetch += "<all-attributes />";
  fetch += "<filter type='and'>";
  fetch += "<condition attribute='new_anabayi' operator='eq' value='" + id + "' />";
  fetch += "<condition attribute='statuscode' operator='eq' value='1' />";
  fetch += "<condition attribute='customertypecode' operator='eq' value='7' />";
  fetch += "</filter></entity></fetch>";

var fetchData = XrmServiceToolkit.Soap.Fetch(fetch);

Upvotes: 0

Views: 787

Answers (1)

dynamicallyCRM
dynamicallyCRM

Reputation: 2980

Add a reference to ClientGlobalContext.js on your web resource.

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

I am assuming you already have referenced the following scripts too?

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="json2.js"></script>
<script type="text/javascript" src="XrmServiceToolkit.js"></script>

Upvotes: 3

Related Questions