Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

facing issue in plugin code.

(0) ShareShare
ReportReport
Posted on by 830

Hi, 

I had a code in my plugin, and my plugin was built as  preopertaion.

The senario is, i always use

if(entity.contains("attributename"))

and my code did enter this if statement last night even when there was no value in that attribute, it happend suddenly and i am unable to figure out why this happened. So to resolve the issue I went and modified the line

If(entity.contains("attributename") && entity.Attribute["attributename"] != null)

then it did not entered this statement and all worked fine.

Can someone help me understand why sudden change was needed for me to implement.

  • Ravi Fulani Profile Picture
    830 on at
    RE: facing issue in plugin code.

    entity.Contains(“fieldname”), if the field specified exists in the list of parameters it will return true. The reason this works is because CRM doesn’t pass null values in the parameter list, so if its null it won’t exist.

    And we are using this thing from past 2 years and it was always working fine. I could not understand why now it created error.

  • Suggested answer
    Ankit Sabharwal Profile Picture
    on at
    RE: facing issue in plugin code.

    Hy Ravi,

    Entity.Contains only check if the object has an attribute present in its object or not. It don't check the value of an attribute 

     if the Entity contains an attribute with the specified name; otherwise, false.

    https://docs.microsoft.com/en-us/dotnet/api/microsoft.xrm.sdk.entity.contains?view=dynamics-general-ce-9

    Please refer to above article.

    Thanks,

    Ankit Sabharwal

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February 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... 292,865 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,723 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans