Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

unable to create linkentity query to fetch the correct value

(0) ShareShare
ReportReport
Posted on by 6

Hello All Experts,

I am trying to creating a query but there seems to be my less understanding which is causing not to get correct value.

it will be really great if some one can help me to get the correct id.

Below is my queryexpression

private Guid fetchconnectionRoleId2(Guid _connectionRoleId, Guid Record2Id, IOrganizationService organizationService)
{
Guid _connectionRoleId2 = new Guid();

QueryExpression reciprocalrolequery = new QueryExpression
{
EntityName = ConnectionRole.EntityLogicalName,
ColumnSet = new ColumnSet(true),
LinkEntities =
{
new LinkEntity
{
JoinOperator = JoinOperator.Inner,
LinkFromEntityName = ConnectionRole.EntityLogicalName,
LinkFromAttributeName = "connectionroleid",
LinkToEntityName = "connectionroleassociation",
LinkToAttributeName = "connectionroleid",
LinkCriteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression
{
AttributeName = "associatedconnectionroleid",
Operator = ConditionOperator.Equal,
Values = { _connectionRoleId}
}
}
}
}
};

EntityCollection resultstemp = organizationService.RetrieveMultiple(reciprocalrolequery);

i need to basically fetch the _connectionRoleId2  but this will be somewhere in the connectionrole entity , but i am not able to write the correct query.

  • MATTGUO Profile Picture
    22,319 Moderator on at
    RE: unable to create linkentity query to fetch the correct value

    Thanks for coming back and sharing the solution.

  • Verified answer
    EmployeeOcta Profile Picture
    6 on at
    RE: unable to create linkentity query to fetch the correct value

    I have got it;s answer.

    simply utilize ConnectionRoleAssociation entity to fetch the connectionrole2id

    var connectionRole2Id = (from associatedRole in xrm.ConnectionRoleAssociationSet

    where associatedRole .AssociatedConnectionRoleId.Equals(_connectionRoleId)

    select associatedRole.ConnectionRoleId);

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,469 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,066 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans