Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

How to concatenate or aggregate field values from multiple records in an associated entity

(0) ShareShare
ReportReport
Posted on by 15

Hello,

I'm looking for a way to concatenate the string values from a field in a related entity. For Instance:  

From Candidate entity:

RelatedOpportunityID     Candidate Name
-------------------      -------------
1                        Mary
1                        John
1                        Sam
2                        Alaina
2                        Edward

On the Opportunity entity, we want a field "Candidates" that "joins" or "rolls up" the values with a comma and space:

ID                  Candidates
--------------      -------------
1                   Mary, John, Sam
2                   Alaina, Edward


How can we acheive this without plugin code?

-Kevin

*This post is locked for comments

  • Suggested answer
    KevinStone Profile Picture
    KevinStone 15 on at
    RE: How to concatenate or aggregate field values from multiple records in an associated entity

    The custom workflow activity seems like the closest to a no-code solution, thank you. We ended up writing a plugin, but want to give it a try next time to avoid more code.

  • KevinStone Profile Picture
    KevinStone 15 on at
    RE: How to concatenate or aggregate field values from multiple records in an associated entity

    Thanks for the answer. I was hoping for a no-code solution

  • Verified answer
    Dynamics365 Rocker Profile Picture
    Dynamics365 Rocker 7,755 on at
    RE: How to concatenate or aggregate field values from multiple records in an associated entity

    Follow below steps to achieve this:

    1. Create Multi text field on opportunity entity with name "Candidates"

    2. Write a plugin on create of Candidates.You will get opportunity id  from target entity, retrieve opportunity Candidates field with help of opportunity id, Append new candidate name in existing opportunity's Candidates then update opportunity:

  • Verified answer
    Kokulan Profile Picture
    Kokulan 18,050 on at
    RE: How to concatenate or aggregate field values from multiple records in an associated entity

    Hi Kevin

    You could use the following Custom Workflow Activity to achieve this. Please follow the link below

    github.com/.../ConcatenateFromQuery.md

    You will have to decide on when you want to do the concatenation.

    I think you could create a workflow on candidates entity, possibly on Create/Field Change and then use the above CWA to concatenate and update the opportunity record with concatenated values.

  • Suggested answer
    Kalpavruksh D365 CoE Profile Picture
    Kalpavruksh D365 CoE 2,545 on at
    RE: How to concatenate or aggregate field values from multiple records in an associated entity

    Hi Kevin,

    You can use webAPI to achieve the same. JavaScript can be used to fetch the data of related records and concatenate.

    If found useful, please mark this answer as verified.

  • sai123456 Profile Picture
    sai123456 320 on at
    RE: How to concatenate or aggregate field values from multiple records in an associated entity

    Are you trying to do this with javascript or c# code?

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 Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,817 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans