如何从CRM查询中获取选项集值的文本? 这是我编写查询的方式:
function nearByCases(addr){
var nearByCasesFetchXML = '<fetch distinct="false" mapping="logical" output-format="xml-platform" version="1.0">' +
'<entity name="incident">' +
'<attribute name="title"/>' +
'<attribute name="ticketnumber"/>' +
'<attribute name="createdon"/>' +
'<attribute name="new_department"/>' +
'<attribute name="new_casetype"/>' +
'<attribute name="incidentid"/>' +
'<attribute name="caseorigincode"/>' +
'<order descending="false" attribute="title"/>' +
'<filter type="and"><condition attribute="new_address" value="'+addr+'" operator="eq"/>' +
'</filter>' +
'</entity>' +
'</fetch>';
nearByCasesFetchXML = "?fetchXml=" + encodeURIComponent(nearByCasesFetchXML);
var html = "";
//var outputText = "Case\t\t\tCreated\n---------------------------------------------------\n";
window.parent.Xrm.WebApi.retrieveMultipleRecords("incident", nearByCasesFetchXML).then(function success(result) {
console.log(result.entities);
if(result.entities.length <=0) {
window.parent.Xrm.Utility.alertDialog("No results found.", null);
return false;
}
else{
for (var casecount = 0; casecount < result.entities.length; casecount++) {
// outputText += result.entities[casecount].ticketnumber+ "\t\t" + result.entities[casecount].title + "\n";
html += "<tr>";
html += "<td>"+result.entities[casecount].title+"</td>";
html += "<td>"+result.entities[casecount].ticketnumber+"</td>";
html += "<td>"+result.entities[casecount].FormattedValues["new_department"].ToString()+"</td>";
html += "<td>"+result.entities[casecount].new_casetype+"</td>";
html += "</tr>";
$("#nearbycases tbody").html(html);
}
return true;
}
//window.parent.Xrm.Utility.alertDialog(outputText, null);
},function (error) {
// Handle error conditions
window.parent.Xrm.Utility.alertDialog(error.message, null);
});
}
这是fetchXml,用于从incident
获取数据,我能够获取所有事件值,但是有一些自定义选项集(new_department
,new_casetype
)仅返回值,不是文字。
那我该如何获取这些选项集的文本。
这是我得到的答复
{ "@odata.etag": "W/"1999118"" , "createdon": "2018-12-13T08:30:34Z" , "createdon@OData.Community.Display.V1.FormattedValue": "12/13/2018 2:30 AM" , "incidentid": "dedfb05b-b1fe-e811-a977-000d3a33eb4e" , "new_casetype": 1 , "new_casetype@OData.Community.Display.V1.FormattedValue": "Abandoned Vehicles" , "new_department": 1 , "new_department@OData.Community.Display.V1.FormattedValue": "Parking Control" , "ticketnumber": "CAS-01001-H2S7L9" , "title": "case for sla 1", }
答案 0 :(得分:0)
sorted( glob.glob("somepath/*.out"))
条目是选项设置值的文本。
您得到的响应包含文本,因此只需引用它即可。
您可以像这样引用它们:
FormattedValue
var results = JSON.parse(this.response);
for (var i = 0; i < results.value.length; i++) {
var departmentCode = results.value[i]["new_department"];
var departmentCodeText = results.value[i]["new_department@OData.Community.Display.V1.FormattedValue"];
}
将是整数,departmentCode
将是文本。
而不是问题中显示的内容:
departmentCodeText
尝试:
html +="<td>"+result.entities[casecount].FormattedValues["new_department"].ToString()+"</td>";