I have following web page html resource in CRM 2013 (see below), I created the JS Scripts as web resources with names also below and reference them in the page, however I can't seem to get XrmSvcToolKit.fetch working (see line in RED), I always get "fetch is not a property referenced", I have the same process only using full JS in another solution same server that throws an alert box and that works perfect. Same JS's.
Any help would be greatly appreciated.
G
=======================
<!DOCTYPE html >
<html lang="en-us">
<head>
<title>Query By ANI Page</title>
<script type="text/javascript" src="dev_jquery.js"></script>
<script type="text/javascript" src="dev_json2.js"></script>
<script type="text/javascript" src="dev_XrmSvcToolKit.js"></script>
<style type="text/css">
body {
font-family: Segoe UI, Tahoma, Arial;
background-color: #d6e8ff;
}
tbody {
background-color: white;
}
th {
background-color: black;
color: White;
}
</style>
<script type="text/javascript">
document.onreadystatechange = function() {
if (document.readyState == "complete") {
getDataParam();
}
}
function getDataParam() {
//Get the any query string parameters and load them into the vals array
var vals = new Array();
if (location.search != "") {
vals = location.search.substr(1).split("&");
for (var i in vals) {
vals[i] = vals[i].replace(/\+/g, " ").split("=");
}
//Look for the parameter named 'data'
var found = false;
for (var i in vals) {
if (vals[i][0].toLowerCase() == "data") {
parseDataValue(vals[i][1]);
found = true;
break;
}
}
if (!found) {
noParams();
}
} else {
noParams();
}
}
function queryByANI(datavalue) {
if (datavalue != "") {
alert(datavalue);
var accountFetchXML = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
" <entity name='account'>" +
" <attribute name='name' />" +
" <attribute name='primarycontactid' />" +
" <attribute name='telephone1' />" +
" <attribute name='accountid' />" +
" <order attribute='name' descending='false' />" +
" <filter type='and'>" +
" <condition attribute='telephone1' operator='eq' value='" + datavalue + "' />" +
" </filter>" +
" </entity>" +
"</fetch>";
DOESN'T REFERENCE XRMSVCTOOLKIT
var retrievedate = XrmSvcToolkit.fetch({
fetchXml: accountFetchXML,
async: false,
successCallback: function(result) {
return result.entities[0].accountid;
},
errorCallback: function(error) {
throw error;
}
});
} else {
noParams();
}
}
function parseDataValue(datavalue) {
if (datavalue != "") {
var vals = new Array();
vals = decodeURIComponent(datavalue).split("&");
for (var i in vals) {
vals[i] = vals[i].replace(/\+/g, " ").split("=");
}
document.getElementById("ANI").value = vals[i][0];
} else {
noParams();
}
}
function openPage()
{
var ANIResult = queryByANI(document.getElementById("ANI").value);
location.href = "xxxxxxx_dev/main.aspx;pagetype=entityrecord&id=%7B"+ ANIResult +"%7D";
}
function noParams() {
var message = document.createElement("p");
setText(message, "No ANI was passed to this page");
document.body.appendChild(message);
}
//Added for cross browser support.
function setText(element, text) {
if (typeof element.innerText != "undefined") {
element.innerText = text;
} else {
element.textContent = text;
}
}
</script>
</head>
<body>
<p>Based on the ANI passed, you can jump to the Account using the link below:</p>
<table>
<thead>
<tr>
<th>ANI</th>
<th>URL</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="text" id="ANI"></td>
<td><a href ="javascript:openPage()">Account Link</a></td>
</tr>
</tbody>
</table>
</body>
</html>