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