Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Display all marketing lists to which an account's contacts belong

(0) ShareShare
ReportReport
Posted on by

So... I need to have a spot on an account page where it displays all the marketing lists that the contacts related to that account belong to. 

I have historically used marketing lists to track trade show attendance for our contacts, but now I've been asked to track them on an account and contact level... and to have that info easily accessible right from the account page. I honestly have no idea what the easiest way to do this is. 

I've been chasing a solution around for this for a while, and I'm still not sure how to even hint at the answer. I thought this would be an easy one to solve :( Murphy strikes again. 

Any help or direction on this would be greatly appreciated. 

*This post is locked for comments

  • flydancer1 Profile Picture
    80 on at
    RE: Display all marketing lists to which an account's contacts belong

    Hi Adrian, how can I do this? I cannot figure out how to tailor the subgrid in this way.

  • Radu Chiribelea Profile Picture
    6,667 on at
    RE: Display all marketing lists to which an account's contacts belong

    Hi Samus,

    Within your iframe you can do pretty much what you want - you own the content there.

    See if this article gets you where you need to go: www.encodedna.com/.../populate-json-data-to-html-table-using-javascript.htm

    Regards,

    Radu

  • Community Member Profile Picture
    on at
    RE: Display all marketing lists to which an account's contacts belong

    Okay, I have the retrieveMultiple function assembled with the correct fetchXml. However, I have no clue how to get a subgrid working with that information. A lot of what I'm reading seems to say that passing fetch to subgrids isn't supported, is bad practice, can break at any time. Is there a supported way to pull the info into a grid/table/view?

    Additionally- how? I've been trying at a number of different methods, and most are beyond my understanding. I'm sorry to ask for hand-holding here, but I'm pretty lost D:

  • Suggested answer
    Radu Chiribelea Profile Picture
    6,667 on at
    RE: Display all marketing lists to which an account's contacts belong

    Basically your logic is following

    1. Open the Account form

    2. On the account form set up an IFrame that is running a JavaScript Function triggered once the Iframe is fully loaded

    3. The function can use the CRM Client side API to pull the AccountId from the context and insert that into a fetchXml string similar to what i pasted above

    4. Use the built in retrieveMultiple function and pass the fetchXml as a parameter - this will retrieve the marketing lists from the CRM Server for the child contacts of the account

    5. Once data is retrieved populate a custom grid / table with the marketing lists within the Iframe.

    Hope this helps,

    Radu

  • Community Member Profile Picture
    on at
    RE: Display all marketing lists to which an account's contacts belong

    Okay I think I understand what you're getting at here, but wouldn't this only pull based off a static GUID? I need a grid/field/frame I can slap on the account form that will update for whatever account I happen to be on.

    I'll be honest, I don't understand at all what I'm supposed to do with the retrieveMultpleRecords capability there. I'm only vaguely familiar with iFrames, and haven't dealt with much beyond .ui stuff. Can you please explain further?

  • Community Member Profile Picture
    on at
    RE: Display all marketing lists to which an account's contacts belong

    I need all contacts, not just the Primary :/

  • Suggested answer
    Adrian Begovich Profile Picture
    1,025 Super User 2025 Season 1 on at
    RE: Display all marketing lists to which an account's contacts belong

    Hi Radu,

    It covers the Primary Contact. Further customisation is required to cover all related contacts.

  • Radu Chiribelea Profile Picture
    6,667 on at
    RE: Display all marketing lists to which an account's contacts belong

    Hi Adrian,

    Would cover only the Primary Contact or would it cover also all the other child contacts?

    Regards,

    Radu

  • Suggested answer
    Radu Chiribelea Profile Picture
    6,667 on at
    RE: Display all marketing lists to which an account's contacts belong

    Hi,

    From the advanced find you can download the fetchXml and use that as a startingpoint.

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
      <entity name="list">
        <attribute name="listname" />
        <attribute name="type" />
        <attribute name="createdfromcode" />
        <attribute name="lastusedon" />
        <attribute name="purpose" />
        <attribute name="listid" />
        <order attribute="listname" descending="true" />
        <link-entity name="listmember" from="listid" to="listid" visible="false" intersect="true">
          <link-entity name="contact" from="contactid" to="entityid" alias="aa">
            <filter type="and">
              <condition attribute="parentcustomerid" operator="eq" value="{<<ACCOUNT_ID_HERE>>}" />
            </filter>
          </link-entity>
        </link-entity>
      </entity>
    </fetch>

    You then need to replace the <<ACCOUNT_ID_HERE>> with the GUID of the account. For CRM 9.X you can use https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/formcontext-data-entity/getid. For earlier versions you need to look up the equivalent.

    Once you have the fetchxml and the accountid, you can use the built in retrieveMultipleRecords method - see for CRM 9.X https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-webapi/retrievemultiplerecords . For earlier builds you would need to generate the GET request yourself. The request would look very much like: YourCrmOrgURL/api/data/v9.0/lists?fetchXml=%3Cfetch%20version%3D%221.0%22%20output-format%3D%22xml-platform%22%20mapping%3D%22logical%22%20distinct%3D%22true%22%3E%0A%20%20%3Centity%20name%3D%22list%22%3E%0A%20%20%20%20%3Cattribute%20name%3D%22listname%22%20%2F%3E%0A%20%20%20%20%3Cattribute%20name%3D%22type%22%20%2F%3E%0A%20%20%20%20%3Cattribute%20name%3D%22createdfromcode%22%20%2F%3E%0A%20%20%20%20%3Cattribute%20name%3D%22lastusedon%22%20%2F%3E%0A%20%20%20%20%3Cattribute%20name%3D%22purpose%22%20%2F%3E%0A%20%20%20%20%3Cattribute%20name%3D%22listid%22%20%2F%3E%0A%20%20%20%20%3Corder%20attribute%3D%22listname%22%20descending%3D%22true%22%20%2F%3E%0A%20%20%20%20%3Clink-entity%20name%3D%22listmember%22%20from%3D%22listid%22%20to%3D%22listid%22%20visible%3D%22false%22%20intersect%3D%22true%22%3E%0A%20%20%20%20%20%20%3Clink-entity%20name%3D%22contact%22%20from%3D%22contactid%22%20to%3D%22entityid%22%20alias%3D%22aa%22%3E%0A%20%20%20%20%20%20%20%20%3Cfilter%20type%3D%22and%22%3E%0A%20%20%20%20%20%20%20%20%20%20%3Ccondition%20attribute%3D%22parentcustomerid%22%20operator%3D%22eq%22%20uiname%3D%22Test%20Company%22%20uitype%3D%22account%22%20value%3D%22%7B04DB747E-3BD6-E811-A967-000D3A2CBE72%7D%22%20%2F%3E%0A%20%20%20%20%20%20%20%20%3C%2Ffilter%3E%0A%20%20%20%20%20%20%3C%2Flink-entity%3E%0A%20%20%20%20%3C%2Flink-entity%3E%0A%20%20%3C%2Fentity%3E%0A%3C%2Ffetch%3E

  • Suggested answer
    Adrian Begovich Profile Picture
    1,025 Super User 2025 Season 1 on at
    RE: Display all marketing lists to which an account's contacts belong

    Hi SamusFairchild,

    Marketing Lists are stored in the List entity. You can create a Sub-Grid on the account form and tailor it to display the marketing lists from the contact related to the account record.

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans