Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

entity getvalue extension method?

(0) ShareShare
ReportReport
Posted on by

Hello, has anyone here created a GetValue extension method for Entity? For example, consider the following scenario that sets a local variable to an entity attribute value:

string myVal;
if (myEntity.Attributes.Contains("new_myfield"))
myVal = account2011["new_myfield"];

An extension method could simplify this code to:

var myVal = myEntity.GetValue("new_myfield");

Seems logical to encapsulate this common code in an extension method. So has anyone here done this as part of an implementation?

*This post is locked for comments

  • Suggested answer
    Surmeet Singh Profile Picture
    3,075 on at
    RE: entity getvalue extension method?

    Hi Andrew,

    GetAttrbuteValue<T>("attributename") is available and also eliminates the use of "myEntity.Attributes.Contains("new_myfield")"  line as it returns null instead of giving an error of key not present in disctionary.

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

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

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
dkrishna Profile Picture

dkrishna 6

Featured topics

Product updates

Dynamics 365 release plans