title: CRM 2011: Insert condition to a fetchXML query using javascript
body: <p>I have the following fetch XML query:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;fetch mapping="logical"&gt;
      &lt;entity name="salesorder"&gt;
          &lt;attribute name="salesorderid"/&gt;
          &lt;attribute name="new_type"/&gt;
          &lt;attribute name="new_solomonswonumber"/&gt;
          &lt;attribute name="new_resolutioncode"/&gt;
          &lt;attribute name="new_rentalsaleindicator"/&gt;
          &lt;attribute name="new_preferredphone"/&gt;
          &lt;attribute name="name"/&gt;
          &lt;attribute name="new_equipment"/&gt;
          &lt;attribute name="customerid"/&gt;
          &lt;order attribute="new_type" descending="false"/&gt;
          &lt;filter type="and"&gt;
              &lt;condition attribute="salesorderid" operator="eq" value="5AC5CBAC-25A0-E211-92B3-00155D815016"/&gt;&lt;/filter&gt;
          &lt;link-entity name="new_entity" from="new_entityid" to="new_entitylookup"&gt;
              &lt;filter type="and"&gt;
                  &lt;attribute name="new_street1"/&gt;
                  &lt;attribute name="new_province"/&gt;
                  &lt;attribute name="new_postalcode"/&gt;
                  &lt;attribute name="new_city"/&gt;
              &lt;/filter&gt;
          &lt;/link-entity&gt;
      &lt;/entity&gt;&lt;/fetch&gt;
  </code></pre>
  
  <p>I have a business need where I need to insert the following condition using java script:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;condition attribute='new_entityid' operator='eq' value='10ad18f6-c384-e211-b04d-78e3b50834b8'/&gt;
  </code></pre>
  
  <p>So that the final fetchxml is as follow:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;fetch mapping="logical"&gt;
      &lt;entity name="salesorder"&gt;
          &lt;attribute name="salesorderid"/&gt;
          &lt;attribute name="new_type"/&gt;
          &lt;attribute name="new_solomonswonumber"/&gt;
          &lt;attribute name="new_resolutioncode"/&gt;
          &lt;attribute name="new_rentalsaleindicator"/&gt;
          &lt;attribute name="new_preferredphone"/&gt;
          &lt;attribute name="name"/&gt;
          &lt;attribute name="new_equipment"/&gt;
          &lt;attribute name="customerid"/&gt;
          &lt;order attribute="new_type" descending="false"/&gt;
          &lt;filter type="and"&gt;
              &lt;condition attribute="salesorderid" operator="eq" value="5AC5CBAC-25A0-E211-92B3-00155D815016"/&gt;&lt;/filter&gt;
          &lt;link-entity name="new_entity" from="new_entityid" to="new_entitylookup"&gt;
              &lt;filter type="and"&gt;
  &lt;condition attribute='new_entityid' operator='eq' value='10ad18f6-c384-e211-b04d-78e3b50834b8'/&gt;
                  &lt;attribute name="new_street1"/&gt;
                  &lt;attribute name="new_province"/&gt;
                  &lt;attribute name="new_postalcode"/&gt;
                  &lt;attribute name="new_city"/&gt;
              &lt;/filter&gt;
          &lt;/link-entity&gt;
      &lt;/entity&gt;&lt;/fetch&gt;
  </code></pre>
  
  <p>Any idea how to do this ?</p>
  
  <p>Thanks and best regards..</p>