2017-05-08 5 views
-1

Microsoft Dynamics CRM 2016에서 작업 중입니다. 리드 양식에 description 필드가 있으며 HTML 웹 리소스가 추가되었습니다. CRM 양식에 description 값을 입력하면 내 HTML 웹 리소스에 값이 표시됩니다.Microsoft Dynamics CRM 양식에서 html 웹 리소스로 가치를 얻는 방법

어떻게 달성 할 수 있습니까?

HTML 웹 리소스 코드 :

  • 사용자 정의 매개 변수를 추가 : 내가 가지고있는 웹 자원의 특성 그리고

    <html> 
    <head> 
    <script src="../ClientGlobalContext.js.aspx" type="text/javascript"></script> 
    <script text="text/javascript"> 
        var description = Xrm.Page.getAttribute("description").getValue(); 
    </script> 
    </head> 
    <body> 
    <table> 
        <thead><tr><th>Parameter</th><th>Value</th></tr></thead> 
        <tbody> 
        <tr><td>description</td><td id="description">null</td></tr> 
    
        </tbody> 
    </table> 
    </body> 
    </html> 
    

    는 (데이터) = RelatedEntity =이 & RelatedField = 설명을 이끌고

  • 매개 변수로 레코드 개체 유형 코드와 고유 식별자를 전달하는 옵션을 활성화했습니다.
  • 이 추가되었습니다. description 보류 (fending)
+0

문제를 풀려고하면 질문을 확장해야합니다 (예 : 시도한 하나 이상의 솔루션을 설명하지만 당신을 위해 일하지 않고 * 왜 * 그들이 당신을 위해 작동하지 않는지 지정하십시오.) 그렇지 않으면 질문은 귀하의 부분에 대한 연구 부족으로 인해 downvoted되고 무시됩니다. 또한 CRM 버전 (2016 의미 8.0 또는 8.1?) – Alex

답변

1

description 속성에 JavaScript onChange() 이벤트를 첨부 할 수 있습니다. 이벤트는 설명 값을 가져온 다음 HTML 컨트롤에서 요소를 가져온 다음 요소의 값을 description 속성 값과 같게 설정합니다. 여기

는 보일 수 있습니다 방법의 예 :

function descriptionOnChange() { 
    // Get the value of the description attribute. 
    var description = Xrm.Page.getAttribute('description').getValue(); 

    // Get the HTML iFrame object. 
    var iFrame = Xrm.Page.ui.controls.get('IFRAME_WebResourceName').getObject(); 

    // Get the element from the iFrame. 
    var element = iFrame.contentWindow.document.getElementById('htmlDescription'); 

    // Set the element's value. 
    element.value = description; 
} 

참고 : 스크립트가있는 iFrame의 속성에서 비활성화되지 않은 프레임 간 확인하십시오

cross-frame scripting enabled


당신을 도메인 간 iFrame 요청이 차단 된 경우 오류가 발생할 수 있습니다. 설명 및 해결 방법은 this post을 참조하십시오.

다음과 같을 수 CRM에서 해결의 구현 :

<script> 
    window.addEventListener('message', function(event) { 
     if (~event.origin.indexOf('https://<yourCRMUrl>')) { 
      document.getElementById('htmlDescription').value = event.data; 
     } else { 
      return; 
     } 
    }) 
</script> 
  • 변경하여 description의 내용 :

    1. 가에 <script> 태그를 추가 메시지를 받아 처리하여 HTML의 <body> 속성의 onChange() 이벤트를 다음으로 변경합니다.

      var description = Xrm.Page.getAttribute("description").getValue(); 
      var iFrame = Xrm.Page.ui.controls.get('IFRAME_WebResourceName').getObject(); 
      
      iFrame.contentWindow.postMessage(description, '*'); 
      
    2. 코드는 당신이 자신의 웹 리소스로 이동할 수 있습니다 성장함에 따라,

      <html> 
       
      <head> 
       
      <script src="ClientGlobalContext.js.aspx" type="text/javascript"></script> 
       
      <script type="text/javascript"> 
       
      function onLoad() { 
       
          var description = parent.Xrm.Page.getAttribute("description").getValue(); 
       
          document.getElementById("description").innerHTML = description; 
       
      } 
       
      </script> 
       
      </head> 
       
      <body onload="onLoad()"> 
       
      <table> 
       
          <thead><tr><th>Parameter</th><th>Value</th></tr></thead> 
       
          <tbody> 
       
          <tr><td>description</td><td id="description">null</td></tr> 
       
          </tbody> 
       
      </table> 
       
      </body> 
       
      </html>

      또한, 그것은이 같은 HTML 헤드에 포함 :

    당신은
  • +0

    포함하거나 WebAPI에서 필드의 값을 표시 할 웹 리소스를 만들고 폼에서 iframe onsave 새로 고침 – Alex

    +0

    제한된 가정하에 꽤 많은 가정을했습니다. 질문에있는 정보. 하나는 HTML iFrame이 데이터를 더 빨리받을 수있게 될 것입니다. –

    +0

    답장을 보내 주셔서 감사합니다. 나는 내 질문을 편집했다. 그걸 기반으로 나를 도울 수 있습니까? – pkm

    0

    이런 식으로 뭔가를 시도 할 수 있습니다 :

    <script src="myLibrary.js" type="text/javascript"></script>