2
有時(實際上大多數情況下)當我嘗試設置查找字段值時,該值設置爲可讀,但字段本身在表單上看起來空白。 這可能是爲什麼?傳遞給setSimpleLookupValue
的所有參數看起來都正確。CRM 2011設置表單字段值但顯示保持空白
有關爲什麼會發生這種情況的任何想法?
這是大部分工作的功能:
function sgc_hr_getManager() {
var testContactId = Xrm.Page.getAttribute("sgc_hr_case_initialcontact").getValue();
if (testContactId != null) {
// do nothing - the field already has a value
} else {
var employeeVal = Xrm.Page.getAttribute("customerid").getValue();
if(employeeVal != null && employeeVal[0] && employeeVal[0].id != null) {
var employeeId = Xrm.Page.getAttribute("customerid").getValue()[0].id;
employeeId = employeeId.replace('{','').replace('}','');
SDK.REST.retrieveRecord(employeeId, 'Contact', null, null, function(employee) {
var managerId = employee.sgc_hr_ManagerId.Id;
if(managerId != null) {
SDK.REST.retrieveRecord(managerId, 'Contact', null, null, function(manager) {
// the following function call correctly sets the value
// but the control display is usually left blank
setSimpleLookupValue('sgc_hr_case_initialcontact', 'Contact', manager.ContactId, manager.FullName);
}, function(a) {
alert('An error occured! Unable to retrieve postholder record ' + managerId);
});
}
}, function(a) {
alert('An error occured! Unable to retrieve postholder record ' + employeeId);
})
} else {
alert('Cannot get employee details');
}
}
}
的setSimpleLookupValue功能是標準之一,如下所示:
function setSimpleLookupValue(LookupId, Type, Id, Name) {
var lookupReference = [];
lookupReference[0] = {};
lookupReference[0].id = Id;
lookupReference[0].entityType = Type;
lookupReference[0].name = Name;
Xrm.Page.getAttribute(LookupId).setValue(lookupReference);
}
有趣的 - 這似乎已修復它。任何想法爲什麼? – CompanyDroneFromSector7G
只讀字段不會提交給數據庫進行更新。正因爲如此,你需要'告訴CRM'來包含這個領域。 – lazarus
當然,但這不是問題 - 它被保存,只是在設置值後才顯示。哦,它現在有用! – CompanyDroneFromSector7G