2014-09-03 5 views
0

Id가 00000000-0000-0000-0000-000000000000 인 Savedquery가있는 경우은 CRM 2013 팀 조회에 대한 사용자 지정보기를 설정할 때이 코드를 사용하면 작동합니다. CRM 2011CRM 2013 조회의 addCustomView

// Set the Owning Team View based on the account selected 
function setOwningTeamView(entityFieldName, lookupFieldName, resetSelection) { 
    // Get the selected entity 
    var account = Xrm.Page.getAttribute(entityFieldName).getValue(); 

if (account != null) { 
    var accid = account[0].id; 
    var accname = account[0].name; 

    if (resetSelection == true) { 
     // reset old selection for Contact 
     Xrm.Page.getAttribute(lookupFieldName).setValue(null); 
    } 

    // use randomly generated GUID Id for the view 
    var viewId = "{0CBC820C-7033-4AFF-9CE8-FB610464DBD3}"; 
    var entityName = "team"; 

    // give the custom view a name 
    var viewDisplayName = "Teams applicable to " + accname + ""; 

    var accountBU = SDK.REST.retrieveRecordSync(Xrm.Page.getAttribute("a_account").getValue()[0].id, "Account", "OwningBusinessUnit", ""); 
    var relatedBusinessUnits = SDK.REST.retrieveMultipleRecordsSync("BusinessUnit", "?$select=BusinessUnitId,Name&$filter=a_Type/Value eq 1"); 
    var FetchXMLBU = ""; 
    for (var i = 0; i < relatedBusinessUnits.results.length; i++) { 
     FetchXMLBU += "<value>" + relatedBusinessUnits.results[i].BusinessUnitId + "</value>" 
    } 

    debugger; 

    // find all contacts where parent customer is the account selected and where the Contact record is active 
    var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" 
     + "<entity name='team'>" 
     + "<attribute name='teamid' />" 
     + "<attribute name='name' />" 
     + "<attribute name='description' />" 
     + "<attribute name='businessunitid' />" 
     + "<filter>" 
     + "<condition attribute='businessunitid' operator='in'>" 
     + "<value>" + accountBU.OwningBusinessUnit.Id + "</value>" 
     + FetchXMLBU 
     + "</condition>" 
     + "</filter>" 
     + "</entity>" 
     + "</fetch>"; 

    // build Grid Layout 
    var layoutXml = "<grid name='resultset' " + 
     "object='1' " + 
     "jump='teamid' " + 
     "select='1' " + 
     "icon='0' " + 
     "preview='0'>" + 
     "<row name='result' id='teamid'>" + 
     "<cell name='name' width='200' />" + 
     "<cell name='businessunitid' width='200' />" + 
     "<cell name='description' width='400' />" + 
     "</row>" + 
     "</grid>"; 

    // add the Custom View to the indicated [lookupFieldName] Control 
    Xrm.Page.getControl(lookupFieldName).addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true); 
    //The following line is the an unsupported way of disabling the View Picker, currently there is no supported way. 
    document.getElementById(lookupFieldName + "_i").setAttribute("disableViewPicker", "1"); 
    //document.getElementById(lookupFieldName).setAttribute("disableViewPicker", "1"); 
} 
} 

나는 in this thread 설명으로 문제가 SDK.REST에 전화와 함께으로 의심하지만, accountBUrelatedBusinessUnits의 결과는 정확합니다. I가 제외하고 동일한 방법으로 와 사용자 정의 fetchXMLlaoyoutXML고객 조회보기를 설정하고있어

var systemUserTeam = SDK.REST.retrieveMultipleRecordsSync("TeamMembership", 
       "$select=TeamId&$filter=TeamId eq guid'" 
       + Xrm.Page.getAttribute("aux_owningteamid").getValue()[0].id 
       + "' and SystemUserId eq guid'" 
       + Xrm.Page.getAttribute("ownerid").getValue()[0].id 
       + "'"); 
    if (systemUserTeam.results.length != 1) { 

:

나는 올바른 행동과 같은 다른 SDK 호출 aith를 사용했다 SDK에 대한 호출

SDK 호출을 변경하면 어떻게 작동합니까?

답변

2

코드를 다시 작성하는 것이 싫다면 이제 사용자 지정 필터를 조회에 추가하는 더 쉽고 지원되는 방법이 있습니다. 기존보기를 사용하여 preFilter를 적용 할 수 있습니다.

This blog post이 좋은 예입니다.

+0

덕분에, 나는 이미 블로그를 확인하지만 사용자 정의보기를 필요로하는 내 경우에는, 당신이 좀 더 많은 정보를 제공하시기 바랍니다 수 addCustomView – Jorge

0

layoutxml- objecttypecode 1의 object = '1'은 아마도 팀에서 계정을 만들 때 계정에서보기를 만들려고한다는 것을 의미합니다. 따라서 CRM은 계정에 대한 사용자 지정보기를 만들고 팀에 대해 호출하려고합니다. 내가 믿는 팀은 9 세입니다. 그 변화가 잘 되었으면 좋았을 것입니다. 9가 아닌 경우 DynamicsXRMtools 솔루션을 다운로드하여 설치하고 CRM 메타 데이터를 확인하십시오.

1

addCustomViewOwner 조회에는 작동하지 않습니다. Owner 조회는 사용자 소유 레코드를 할당하는 데 사용됩니다.

는 링크 - https://msdn.microsoft.com/en-us/library/gg334266.aspx#BKMK_addCustomView

+0

을 사용해야합니다? 그것이 그대로, 귀하의 게시물은 실제 답변보다 더 많은 의견입니다 ... – Badacadabra

+0

@Badacadabra - 사용자 정의 필드, 양식에 보이지 않게 시스템 필드 "ownerid"를 만들 수 있습니다. 사용자 지정 필드에서 원하는 "addCustomView"를 구현하고 플러그 인을 통해 서버에서 "AssignRequest"를 만듭니다. – pennant

관련 문제