Search

Get Record Guid by name

//Change the fetch query as per use
 
/* Jscript */


document.getBuGuid = function(product_nm){
//var _d_fxml = "";
var _d_fxml = "<fetch mapping='logical'><entity name='new_businessinterest'><no-attrs/><filter type='and'><condition attribute='new_name' operator='eq' value='"+product_nm+"'/></filter></entity></fetch>";
//var _e_fxml = CrmEncodeDecode.CrmHtmlEncode(_d_fxml);
var soap_header= document.genSoap(_d_fxml);
var ajResponse = document.ajaxSoap(soap_header);

var oXmlDoc = new ActiveXObject("Microsoft.XMLDOM"); //Create an XML document that you can parse.o
oXmlDoc.async = false;

oXmlDoc.loadXML(ajResponse); //Load the XML document that has the UnEncoded results.
var results = oXmlDoc.getElementsByTagName('resultset');
var bu_guid = oXmlDoc.selectNodes("//new_businessinterestid")[0].text;
var re1='.*?'; // Non-greedy match on filler
var re2='([A-Z0-9]{8}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{12})'; // SQL GUID 1
var p = new RegExp(re1+re2,["i"]);
var m = p.exec(bu_guid);
if (m != null)
{
var guid1=m[1];
return(guid1.replace(/ }
};