Recently i was asked to connect a CRM form to a webservice, the script had to provide some details from a field as a parameter and the response had to be recorded on the form.
Below is a snippet of how this was achieved.
{codecitation style="brush: javascript;"}
function GetDetailsFromWebService(scf)
{
if (Xrm.Page.getAttribute(scf).getValue() !== null)
{
var xmlHttp;
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
var WS_SERVER = "http://blah.com";
var strUrl = "";
//Build the url
strUrl = WS_SERVER + "/Webservice.LocationFile";
// Set the lookup string
strUrl += "?Parameter=" + Xrm.Page.getAttribute(scf).getValue();
xmlHttp.open("GET",strUrl, false);
xmlHttp.send();
var XMLDoc = new ActiveXObject("Microsoft.XMLDOM");
XMLDoc.setProperty("SelectionLanguage", "XPath");
XMLDoc.loadXML(xmlHttp.responseText);
//Read XML Document and Extract Data
}
else
{
Alert("Error");
}
}
{/codecitation}
Enjoy
Jonathan