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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to retrieve Guid of a link-entity?

(0) ShareShare
ReportReport
Posted on by

I've coded a method to query a queue's (related)mailbox state. In order to do that I need to pass down the queue's related mailbox Guid - "mailboxid". The mailbox in this case is a link-entity.

At the moment I can get the Guid of that queue easily using the below cast. But I'm wondering how I can retrieve the Guid of the queue's mailbox.

Question:

How can I retrieve/cast the Guid of a link entity?

Sample cast on queue Guid:

int selectedIndexQueue = unenabledMailboxQueueListBox.SelectedIndex;
Entity selectedQueue = UnenabledMailBoxQueueStringList[selectedIndexQueue];
Guid selectedQueueGuid = (Guid)selectedQueueMailbox.Attributes["queueid"];

FetchXML (detailing the query on related unenabled mailboxes of queues):

 

<?xml version="1.0"?>

-<fetch distinct="false" mapping="logical" output-format="xml-platform" version="1.0">


-<entity name="queue">

<attribute name="name"/>

<attribute name="emailaddress"/>

<attribute name="queueid"/>

<order descending="false" attribute="name"/>


-<link-entity name="mailbox" alias="ab" to="defaultmailbox" from="mailboxid">


-<filter type="and">


<condition attribute="statecode" value="1" operator="eq"/> </filter> </link-entity> </entity> </fetch>



 

 


*This post is locked for comments

I have the same question (0)
  • Verified answer
    NatrajY Profile Picture
    3,040 on at

    In this case it is easier to retrieve this from queue itself. Just use selectedQueueMailbox.GetAttributeValue<EntityReference>("defaultmailbox").Id, as you are using this attribute to link it to mailbox.

    If you want to still retrieve it from the link entity, add mailboxid to the retrieve columns on the link and use (Guid)selectedQueueMailbox.GetAttributeValue<AliasedValue>("ab.mailboxid").Value. You'll have to refer the attributes on the link entity prefixed with their alias, which in this case is ab.

  • Suggested answer
    Aiden Kaskela Profile Picture
    19,696 on at

    Hi,

    You can get back an attribute on a linked entity by including the attribure node in the link-entity section, like this:

          <link-entity name='attributemap' alias='attributemap' to='entitymapid' from='entitymapid' link-type='inner'>
             <attribute name='sourceattributename'/>
             <attribute name='targetattributename'/>
          </link-entity>
    


    (source: https://msdn.microsoft.com/en-us/library/gg328117.aspx)

    Hope this helps! I'd appreciate if you'd mark this as Answering your question.

    Thanks,

      Aiden

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans