2012-10-10 4 views
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); 
    } 

답변

3

봅니다 다음 줄을 추가

Xrm.Page.getAttribute("sgc_hr_case_initialcontact").setSubmitMode("always"); 
+0

흥미 롭군요. 왜 그런가? – CompanyDroneFromSector7G

+0

Readonly 필드는 업데이트를 위해 DB에 제출되지 않습니다. 그렇기 때문에이 필드를 포함 시키려면 'CRM에 알리기'가 필요합니다. – lazarus

+0

물론, 그게 문제는 아니 었습니다. 값이 저장된 후에는 저장되지 않고 그냥 표시되지 않았습니다. 오 잘 지금 작동합니다! – CompanyDroneFromSector7G