2012-12-12 2 views
0

CRM 2011의 사용자 지정 작업을하고 있습니다. 활동을 기반으로하는 사용자 지정 엔터티를 만들어 계정과 관계를 만들었습니다 계정 양식은 사용자 정의 디스플레이에 전원을 공급할 웹 리소스를 가리키는 사용자 정의 탐색 링크를 만들었습니다 (JavaScript가있는 html 페이지).활동 표시 사용자 지정 탐색 링크를 클릭 할 때

웹 자원은 표준 관계 링크 대신 사용되며, 상자 기능에서 제공하는 목록보기뿐만 아니라 목록 및 미리보기 표시를 수행하기 때문에 표준 관계 링크 대신 사용됩니다.

사용자가 탐색 링크를 누르고 사용자가 섹션을 클릭 할 때마다 클릭 할 때 표시되는 활동 탭 (액티비티 리본 탭)을 계정 양식에 표시하려고합니다. 활동 내비게이션 링크. 탭 표시 규칙에 대한 많은 정보를 찾을 수없는 것 같습니다. 가능한 경우이를 수행해야하는 장소라고 생각합니다.

또한 자바 스크립트를 사용하면 (내가 찾지 못했지만) 잘 작동합니다.

+0

사용자 정의 탐색 링크가 활동 격자를 열길 원합니까? –

+0

안녕 제임스, 나는 링크를 가지고, 그것은 모든 자바 스크립트와 함께 단순히 HTML 페이지 인 임베디드 리소스입니다. 이 작업을 수행하려면 임베디드 리소스를 표시 할 때 액티비티 리본 탭을 표시해야합니다. – Modika

+0

그럴 가능성이 있다고 생각하지 않습니다. –

답변

2

우리는 해결책이 있습니다.

면책 조항이 솔루션은 대담한 비율의 완전한 해킹이지만 권장되지는 않지만 (지원되는) 문제는 해결되었습니다. 이것은 우리가 클라이언트에 더 잘 맞을 커스텀 솔루션을 구축 할 때 일시적인 기능입니다. 그래서 앞으로 나아가고 있지 않습니다. 그래서 해킹이 우리에게 효과적이었습니다. 또한 스크립트를 작성하는 것이 훨씬 더 효과적 일 수 있습니다.

참고 :이 솔루션은 JQuery와 같은 일부 외부 라이브러리를 사용합니다 & CRM FetchKit

1) 사용자 정의 개체의 관계를 추가하고 우리는 사용자 지정 엔터티를 가지고 있고, 우리가 일을 만들어 계정 : 계정 엔티티에서 사용자 정의 엔티티로의 N 관계. 이것이 우리가 할 수있게 해주는 것은 우리의 커스텀 엔티티의 관련 뷰를 가리키는 네비게이션 링크를 계정 폼 상에 생성하는 것입니다. 링크가 들어가면 변경 사항을 저장하고 게시합니다.

2) 새로운 탐색 링크의 ID를 가져가 저장하고 게시 한 후 우리는 라이브 뷰로 이동하여 IE 개발자 도구를 사용하여 우리의 ID를 얻을 수 있도록 위의 링크는 현재 양식에 있어야 을 생성 우리가 onclick을 붙잡고 나중에 그것으로 어떤 것을 할 필요가있는 링크. 탐색 링크의 OnClick을 장식

3) 우리가 ID를 가지고 우리가 몇 가지 추가 기능과 함께 온 클릭을 장식 할 를 만들었습니다.우리는이 새로운 웹 리소스를 생성 :

  • "YourCustomEntity" _init : 자바 스크립트 웹 리소스 : 이것은 우리가 만든 링크를 얻을 몇 가지 추가 작업을 수행하기 위해 온 클릭을 변경하기 위해 계정 양식의 온로드에 사용됩니다
  • YourCustomEntity _page : HTML 페이지 웹 리소스 : 원래의 질문에 따라, 우리는 우리가 표준 그리드

코드를 사용할 수없는 이유입니다 미리보기 창을 표시의 추가 요구 사항이 "YourCustomEntity"_init에 대한 코드는 꽤 기본이며 우리의 문제를 해결하기 위해 간단하게 작성된 객체 캐싱 등이 없습니다. 코드에 주석을 추가했습니다. 또한 Entity는 일반 이름이며,이 이름은 사용자 정의 유형의 이름입니다. display : none 대신에 원래의 뷰를 숨김으로 설정했습니다. 왜냐하면 리본이 업데이트되고로드되는 곳이기 때문에 백그라운드에서로드해야하기 때문에 아무 것도 없기 때문에이 스크립트를 계속 진행해야합니다. 우리가 알기를 바랍니다. 그래서 우리는 단지 여기에 모든 코드를 보여 드릴 거예요하지

function previewEntityInit(){ 
    //Catch any navigation link click, we need this because we need to hide our 
    //grid when we are not on the custom entity page 
    $('.ms-crm-Nav-Subarea-Link, .ms-crm-FormSelector-SubItem').click(function() { 

    //Get the id of the link clicked and the frame injected object 
    var id = $(this).attr('id'), 
     cFrame = $('#entity_frame_preview'); 

    //if the frame has already been injected 
    if(cFrame.length !== 0) { 
     //If we are not in the correct section 
     //(i.e. activities nav link was clicked) hide it 
     if (id !== 'nav_new_account_new_entity') { 
      cFrame.attr('style', 'display:none;'); 
     } 
     else{ 
      //The correct link was clicked, so show it 
      cFrame.attr('style', 'display:block; width:100%; height:100%;'); 
      $('#new_account_new_entityFrame').attr('style', 'visibility: hidden;'); 
     } 
    } 
    else{ 
     //This is the first time the correct link has been clicked 
     //So we hide the default associated view and inject our 
     //own iframe point to the YourCustomEntity_page embedded resource we created 
     var src = Xrm.Page.context.getServerUrl(); 
     if (id === 'nav_new_account_new_entity') { 
      $('#new_account_new_entityFrame').attr('style', 'visibility: hidden;'); 

      $('<iframe />', { 
       id: 'entity_frame_preview', 
       src: src + '/WebResources/new_entity_page', 
       width: '100%', 
       height: '100%' 
      }).prependTo('#tdAreas'); 
     } 
    } 
}); 

YourCustomEntity_page :) 것을 사용할 수 있지만 우리는이 링크에 우리를 기반으로 :

Preview Form Link 우리는 다음과 같은 방법을 변경 :

  • 보기 이름 만 하드 코드이며 나머지는 코드 (아래 코드)로 찍습니다.
  • 두 번째 iframe 선택을 사용하지 않고이 HTML을로드하는 간단한 HTML 섹션을 사용하지 않습니다 아래)

없음 하드 코딩은

미리보기를 들어

var server = Xrm.Page.context.getServerUrl();    
var orgName = ""; 

// grid related settings 
var entityId = window.parent.Xrm.Page.data.entity.getId(); 
var entityType = "1"; 
var areaView = "new_account_new_entity"; 
var internalGridElement = "crmGrid_new_account_new_entity"; 
var timeoutKey = null; 

HTML 값

<div id="previewForm" style="display: none;"> <ol> <li><span class="lbl">Account:</span><span id="lblAccount"></span></li> <li><span class="lbl">Created:</span><span id="lblDate"></span></li> <li><span class="lbl">Regarding:</span><span id="lblRegarding"></span></li> <li><span class="lbl">Owner:</span><span id="lblOwner"></span></li> </ol> <div id="subject"> <span class="lbl">Subject:</span><span id="lblSubject" class="value"></span> </div> <div> <span id="lblMsg"></span> </div> </div> 

LoadPreview 코드

이 CRMFetchKit라는 외부 라이브러리를 사용합니다. 이 코드는 실제로 세 가지 가져 오기 호출을 수행합니다.이 코드는 이상적이 아니며 실제로는 하나가되어야합니다 (조인을 사용하면 Google이됩니다.))하지만이 코드는 작동하지 않고 끌기 때문에이 전체 섹션을 3 개로 지정하기로했습니다. 곧 관리되는 솔루션으로 대체하십시오.

function LoadPreviewPane(entity) { 
      if (entity != null) { 
       $('#previewForm').show(); 

       var fetchxml = ['<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">', 
           ' <entity name="new_entity">', 
             '<attribute name="subject" />', 
             '<attribute name="description" />', 
             '<attribute name="createdon" />', 
             '<attribute name="new_account" />', 
             '<attribute name="ownerid" />', 
           ' <filter type="and">', 
           '  <condition attribute="activityid" operator="eq" value="' + entity.Id + '" />', 
           ' </filter>', 
           ' </entity>', 
           '</fetch>'].join(''); 

       CrmFetchKit.Fetch(fetchxml).then(function (results) { 

        var account = window.parent.Xrm.Page.getAttribute("name").getValue(), 
         subject = results[0].getValue('subject'), 
         desc = results[0].getValue('description'), 
         created = new Date(results[0].getValue('createdon')), 
         theDate = created.getDate() + "/" + (created.getMonth() + 1) + "/" + created.getFullYear(), 
         owner = '', 
         regarding = ''; 

        var fetchxml2 = ['<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">', 
           ' <entity name="systemuser">', 
             '<attribute name="fullname" />', 
           ' <filter type="and">', 
           '  <condition attribute="systemuserid" operator="eq" value="' + results[0].getValue('ownerid') + '" />', 
           ' </filter>', 
           ' </entity>', 
           '</fetch>'].join(''); 

        CrmFetchKit.Fetch(fetchxml2).then(function (users) { 
         owner = users[0].getValue('fullname'); 
         $('#lblOwner').html(owner); 
        }); 

        var fetchxml3 = ['<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">', 
        ' <entity name="account">', 
        '<attribute name="name" />', 
        ' <filter type="and">', 
        '  <condition attribute="accountid" operator="eq" value="' + results[0].getValue('new_accountname') + '" />', 
        ' </filter>', 
        ' </entity>', 
        '</fetch>'].join(''); 

        CrmFetchKit.Fetch(fetchxml3).then(function (regardings) { 
         regarding = regardings[0].getValue('name'); 
         $('#lblRegarding').html(regarding); 
        }); 

        $('#lblAccount').html(account); 
        $('#lblSubject').html(subject); 
        $('#lblMsg').html(nl2br(desc)); 
        $('#lblDate').html(theDate);       

       }); 
      } 
     } 
+0

해결책을 업로드하고 지원되지 않는 점을 인정하는 +1 +1에 감사드립니다. –

관련 문제