web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Get Value of the Current Record for FetchXML

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Verified answer
    Shahbaaz Ansari Profile Picture
    6,211 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
    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 - MVP Profile Picture
    30,188 Moderator 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
    55,410 Moderator 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#2
Christoph Pock Profile Picture

Christoph Pock 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans