var curUserid = Xrm.Utility.getGlobalContext().userSettings.userId;
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>"+
"<entity name = 'ns_company' >"+
"<attribute name='ns_companyid' />"+
"<attribute name = 'ns_name' /> "+
"<attribute name = 'ns_number' /> "+
"<order attribute = 'ns_name' descending = 'false' /> "+
"<link-entity name = 'ns_office' from = 'ns_companyid' to = 'ns_companyid' link-type='inner' alias = 'ak' > "+
"<link-entity name = 'ns_user' from = 'ns_officeid' to = 'ns_officeid' link-type='inner' alias = 'al' > "+
"<filter type = 'and' > "+
"<condition attribute = 'ns_systemuserid' operator = 'eq' value = '" + curUserid +"' /> "+
"</filter> "+
"</link-entity> "+
"</link-entity> "+
"</entity> "+
"</fetch>";
var encodedFetchXml ="?fetchXml="+ encodeURI(fetchXml);
Xrm.WebApi.online.retrieveMultipleRecords("ns_company", encodedFetchXml).then(
function success(results) {
if(results.entities.length>0) {
var ns_name = results.entities[0]["ns_name"];
var ns_number = results.entities[0]["ns_number"];
}
},
function (error) {
Xrm.Utility.alertDialog(error.message);
}
);
标签:Xrm,调用,results,JS,entities,fetchXml,FetchXML,var,ns
From: https://www.cnblogs.com/fanxin2015/p/14013349.html