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)

Check , Attribute is not available in entity using IF condition

(0) ShareShare
ReportReport
Posted on by 1,000

I can retrieve the entity in objRecord variable.

Entity objRecord = service.Retrieve(<here retrieve>)

If the value available in new_fieldname it will return in objRecord . so i will check like the following,

if (objRecord .Attributes.Contains("new_fieldname"))
{

}

How can I check the new_fieldname  Does not have value? don't want to check in else part  i need to check only in IF condition? how can I do this ? Is it possible ?

*This post is locked for comments

I have the same question (0)
  • Alagunellaikumar Profile Picture
    6,212 on at

    Hi

    Based on field data type the condition check will be differ. Please find below how to check condition with different datatype.

    if (objRecord .Attributes.Contains("new_fieldname"))

    {

    //String

    if(string.IsNullOrEmpty(objRecord .Attributes["new_fieldname"])

    //EntityReference

    EntityReference objEntityReference=(EntityReference)objRecord .Attributes["new_fieldname"];

    if(objEntityReference!=null && objEntityReference.Id!=null)

    //Int

    if(objRecord .Attributes["new_fieldname"]!=0)

    }

  • vijay12872 Profile Picture
    1,000 on at

    I need to achieve like the following scenario

    if (objRecord .Attributes.DoesnotContain("new_fieldname"))

    {

    }

    But Unfortunate  we cant check use the above code. how can I do it in alternative way

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

    Hello,

    Try following:

    if (!objRecord.Attributes.Contains("new_fieldname"))

    {

    }

  • Suggested answer
    Alagunellaikumar Profile Picture
    6,212 on at

    IF you find answer could you please mark as verified

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