2014-10-20 3 views
1

다음 CML Dynamics 양식에서 Lookup Field를 필터링하는 XML 코드가 있습니다. 필터는 계정 필드에 입력 된 데이터 다음에 사용됩니다. 그러나 계정 필드에는 & 기호가 포함될 수 있으며,이 경우 기호가 XML 형식이 올바르지 않다고 오류가 발생합니다.& Symbol이 XML 코드에서 오류를 일으킬 수 있습니다.

누구든지 문제를 해결할 수 있습니까?

function accountcontact() 
{ 
    Xrm.Page.getControl("new_contactlookup").addPreSearch(function() { addcontactlookup(); }); 

    function addcontactlookup() 
    { 
     var accountID = Xrm.Page.getAttribute("new_companylookup"); 
     var AccountIDObj= accountID.getValue(); 

     if (AccountIDObj != null) 
     { 
      var fetchFilter1 = "<filter type='and'><condition attribute='parentcustomerid' uitype='" + AccountIDObj[0].entityType + "' operator='eq' value='" + AccountIDObj[0].id + "' uiname='" + AccountIDObj[0].name + "' /></filter>"; 
      Xrm.Page.getControl("new_contactlookup").addCustomFilter(fetchFilter1); 
     } 
    } 
} 
+3

그것은'&로 이스케이프해야합니다 '유틸리티 기능 (I 자바 스크립트를 가정) 사용 : [? 자바 스크립트 XML 엔티티를 탈출하는 방법 (http://stackoverflow.com/questions/7918868/how -to-escape-xml-entities-in-javascript) –

+0

필터링 대신 ActiveX를 사용하여 필터를 추가하려는 이유 OOB toools를 사용하여 양식을 수정하는 것만으로 계정으로 문의 하시겠습니까? – AdamV

답변

0

일부 문자는 XML 및 앰퍼샌드 (&)에서 특별한 의미 그 중 하나가 있습니다. 결과적으로 이러한 문자는 각각의 엔티티 참조로 대체 (예 : 문자열 바꾸기)해야합니다. XML 사양 당, XML 5 predefined entities이 있습니다

&lt; < less than 
&gt; > greater than 
&amp; & ampersand 
&apos; ' apostrophe 
&quot; " quotation mark 

다른 방법으로, XML 파서가 파싱하지 않도록 CDATA 섹션 내에서 특수 문자를 포함 할 수 있습니다 "텍스트"문자열을 배치 할 수 있습니다. 예 :

<SomeElement><![CDATA[This & will be ignored]]></SomeElement> 
관련 문제