Wednesday, September 4, 2013

CRM 2011 - Get Fetch in Advanced Find form by javascript

function GetFetch() {
try{
//get FetchXML
var advFind=_mainWindow.$find("advFind"), iOldMode = advFind.get_fetchMode();
var sFetchXml=advFind.get_fetchXml();

//get related information
var FetchXml = sFetchXml;
var LayoutXml= FetchXml.LayoutXml;
var EntityName = FetchXml.EntityName;
var DefaultAdvFindViewId= FetchXml.DefaultAdvancedFindViewId;
var ViewId = FetchXml.QueryId;
var ViewType= FetchXml.QueryObjectType;

//your code
} catch (err) {
                txt = "There was an error on this page.\n\n";
                txt += "Error description: " + err.message + "\n\n";
                txt += "Click OK to continue.\n\n";
                alert(txt);
}

}