Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Get Value of the Current Record for FetchXML

Posted on by Microsoft Employee

I have an Entity B that I open the form to create New from the Contact.  The Contact autopopulates to Entity B.  I have another Entity A that relates to the Contacts via N:N.   I want to get a list of these values with the Contact for my fetchXml.  I have hard coded a value and it works. I have tried #contactid# and it doesn't work and I have tried contactid and it doesn't work either.  Is there anyway to have the value populate with each selected contact?

      <link-entity name="contact" from="contactid" to="contactid" alias="ac">
        <filter type="and">
          <condition attribute="contactid" operator="eq" value= /> 
        </filter>
      </link-entity>


*This post is locked for comments

  • Verified answer
    Shahbaaz Ansari Profile Picture
    Shahbaaz Ansari 6,203 on at
    RE: Get Value of the Current Record for FetchXML

    Hi Marsox,

    You can get the current record id by Xrm.Page.data.entity.getId() and below is the code you can use for passing value. like '"+currentrecordID +"'

    function getcurrentid()

    {

    var currentrecordID = Xrm.Page.data.entity.getId();

    <link-entity name="contact" from="contactid" to="contactid" alias="ac">

           <filter type="and">

             <condition attribute="contactid" operator="eq" value= '"+currentrecordID +"' >

           </filter>

         </link-entity>

    }

    Best Regards,

    Shahbaaz

  • Suggested answer
    Preeti Sharma Profile Picture
    Preeti Sharma 2,678 on at
    RE: Get Value of the Current Record for FetchXML

    Hi,

    Please try as @contactid as below:

    <condition attribute="contactid" operator="eq" value= @contactid/>

    Hope this helps:)

  • Verified answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: Get Value of the Current Record for FetchXML

    I am not sure how you are opening the entity B, but if you are adding the contact entity B, you can get the contact value by using Xrm.Page.getAttribute("new_contactid").getValue()[0].id;

    That will give you the contact id value of the lookup on the entity B form.

    Is that what you are looking for? If not, please provide further details.

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Get Value of the Current Record for FetchXML

    Hi Marsox,

    Could you please share some mor edetails? Where/.how are your executing your fetchxml.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans