locked
dynamic value in fetchxml query RRS feed

  • Question

  • hi i have created a fetxhxml

     

    //Step 1: build fetch xml


    var account_id=Xrm.Page.getAttribute("account_id").getValue();

    var arrFields = ['firstname','lastname'];
    var xml = "<fetch mapping='logical'>" +
    "<entity name='contact'>" +
     "<attribute name='firstname'/>" +
     "<attribute name='lastname'/>" +
     "<filter type='and'>" +
      "<condition attribute='accountidname' operator='eq' value='Abbott'/>" +
     "</filter>" +
    "</entity>" +
    "</fetch>";

    //Step 2: call function and retrieve recordcount [0]
    var iCount =  gFetchValues(xml, arrFields)[0];
    alert(iCount);

     

    on condition line"<condition attribute='accountidname' operator='eq' value='Abbott'/>" +

     

    i want to set value to account_id

     

    how can i set it?

     

    thx


    Software Specialist Crm
    Monday, December 12, 2011 9:11 AM

Answers

  • Hi

     

    Please use following

     

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
      <entity name="contact">
        <attribute name="contactid" />
        <attribute name="lastname" />
        <attribute name="firstname" />
        <order attribute="lastname" descending="false" />
        <link-entity name="account" from="primarycontactid" to="contactid" alias="relatedAccounts">     
            <filter type="and">
              <condition attribute="name" operator="eq" value="Abbott" />
              <condition attribute="accountid" operator="eq" uiname="test1" uitype="account" value="{218B1666-54E4-E011-B285-00155D193A03}" />       
          </filter>
        </link-entity>
      </entity>
    </fetch>
    

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer

     


    Many Thanks -Bhautik Desai xRM Technologies

     code below works for me:)

     

        var _oService;
        var _sOrgName = "";
        var _sServerUrl = Xrm.Page.context.getServerUrl();
    var id=Xrm.Page.getAttribute("new_uyeid").getValue();
    var sFetch = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
    "<entity name='contact'>" +
     "<attribute name='contactid'/>" +
     "<attribute name='fullname'/>" +
     "<filter type='and'>" +
      "<condition attribute='new_uyeid' operator='eq' value='"+id+"'/>" +
     "</filter>" +
    "</entity>" +
    "</fetch>";


    Software Specialist Crm
    • Marked as answer by Ahmet Çankaya Thursday, December 22, 2011 12:23 PM
    Monday, December 12, 2011 3:41 PM

All replies

  • Hi

     

    Please use following

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
      <entity name="contact">
        <attribute name="contactid" />
        <attribute name="lastname" />
        <attribute name="firstname" />
        <order attribute="lastname" descending="false" />
        <link-entity name="account" from="primarycontactid" to="contactid" alias="relatedAccounts">     
            <filter type="and">
              <condition attribute="name" operator="eq" value="Abbott" />
              <condition attribute="accountid" operator="eq" uiname="test1" uitype="account" value="{218B1666-54E4-E011-B285-00155D193A03}" />       
          </filter>
        </link-entity>
      </entity>
    </fetch>
    

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer


    Many Thanks -Bhautik Desai xRM Technologies
    Monday, December 12, 2011 9:40 AM
  • Hi

     

    Please use following

     

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
      <entity name="contact">
        <attribute name="contactid" />
        <attribute name="lastname" />
        <attribute name="firstname" />
        <order attribute="lastname" descending="false" />
        <link-entity name="account" from="primarycontactid" to="contactid" alias="relatedAccounts">     
            <filter type="and">
              <condition attribute="name" operator="eq" value="Abbott" />
              <condition attribute="accountid" operator="eq" uiname="test1" uitype="account" value="{218B1666-54E4-E011-B285-00155D193A03}" />       
          </filter>
        </link-entity>
      </entity>
    </fetch>
    

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer

     


    Many Thanks -Bhautik Desai xRM Technologies

     code below works for me:)

     

        var _oService;
        var _sOrgName = "";
        var _sServerUrl = Xrm.Page.context.getServerUrl();
    var id=Xrm.Page.getAttribute("new_uyeid").getValue();
    var sFetch = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
    "<entity name='contact'>" +
     "<attribute name='contactid'/>" +
     "<attribute name='fullname'/>" +
     "<filter type='and'>" +
      "<condition attribute='new_uyeid' operator='eq' value='"+id+"'/>" +
     "</filter>" +
    "</entity>" +
    "</fetch>";


    Software Specialist Crm
    • Marked as answer by Ahmet Çankaya Thursday, December 22, 2011 12:23 PM
    Monday, December 12, 2011 3:41 PM