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)

Retrieve EntityRerence from an AliasedValue and convert that to a string - FetchXML

(0) ShareShare
ReportReport
Posted on by 255

Hi

I'm retrieving data using FetchXML but I'm struggling to check for the AliasValues, retrieve them and then make them strings for insertion in a SQLserver db.

I have it working for non Alias values as below;

if (c.Attributes.Contains("tri_school1type")){
        gSchoolType1 = c.GetAttributeValue<EntityReference>("tri_school1type").Id;
                }
gSchoolType1 is declared as a Guid then i convert out of the fetch loop to a string with;

var sSchoolType1Guid = gSchoolType1;
string sSchoolType1String = sSchoolType1Guid.ToString();


Many thanks

*This post is locked for comments

I have the same question (0)
  • ashlega Profile Picture
    34,477 on at

    Should be more or less like this:

    object oVal = ((AliasedValue)c.Attributes["alias.attribute"]).Value;

    Guid id= ((EntityReference) oVal).Id;

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Try something like:

    Guid id = ((EntityReference)c.GetAttributeValue<AliasedValue>("aliasname").Value).Id;

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Also it would be good to close thread you opened earlier - community.dynamics.com/.../265357

    Take a minute, open it and mark answers - I'm pretty sure there were such replies.

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