Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum

'opportunity' entity doesn't contain attribute with Name

Posted on by Microsoft Employee

Hello,

I am currently writing a plugin and want to set a field. I can read the field from the opportunity but I cannot write it back somehow. Here is the code:

// global class variable
private const string FieldName_CloneFlag = "pref_cloneflag_boolean";
// [...some more plugin code to retrieve the entity...]
// check the clone flag... if (entity.Contains(FieldName_CloneFlag)) { tracingService.Trace("CloneFlag found"); if (!(bool)entity.Attributes[FieldName_CloneFlag]) { tracingService.Trace("CloneFlag = false... Leaving now."); return; } else { tracingService.Trace("CloneFlag = true... Setting to false now."); // remove the clone flag... Entity e = new Entity(entity.LogicalName); e.Id = entity.Id; e.Attributes.Add(FieldName_CloneFlag, false);
tracingService.Trace("attempting to update now..."); iOrgService.Update(e); tracingService.Trace("updated."); } }


The result in the Plug-In Trace Log is as follows:

CloneFlag found
CloneFlag = true... Setting to false now.
attempting to update now...
PluginClone Exception: 'opportunity' entity doesn't contain attribute with Name = 'pref_cloneflag_boolean' and NameMapping = 'Logical'.

What is weird for me is that I can chose the field in the PluginRegistration toll as filter and read its value in the code. What could be the reason why CRM thinks that the field does not exist?

Thanks! 

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: 'opportunity' entity doesn't contain attribute with Name

    It works after the weekend so it is very likely something cache related (server side).

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: 'opportunity' entity doesn't contain attribute with Name

    It's not like I have not tried to publish - both the custom solution as well as the default solution.

    The issue of this case it that exactly that does not work.

    The region is CRM4 and the version is: 1710 (9.0.2.2646) online

  • Arun Vinoth Profile Picture
    Arun Vinoth 11,613 on at
    RE: 'opportunity' entity doesn't contain attribute with Name

    Pathetic. Blame the metadata cache in server side.

    Yo can try this: Settings - Customizations - Customize the system (Default solution) - Publish All customizations.  

    This will iron out any wrinkles.

    Which region your CRMOL is in? Like crm, crm5,crm8.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: 'opportunity' entity doesn't contain attribute with Name

    It does as I can

    • read it via the plugin
    • it is published on a form (I can see it there)
    • it is selected as filter attribute in the plugin step
  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: 'opportunity' entity doesn't contain attribute with Name

    Yup, I remember there was another thread which claims that it took 3 hours to appear the new field in plugin. Worth trying after some time. If this doesn't fix teh issue then I guess the best option si to contact Microsoft support as they can confirm if this is a bug or not (if you are sure that the field with the same schema name does exists in the system :) )

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: 'opportunity' entity doesn't contain attribute with Name

    Thanks for the link. Seems really like there is a new problem with publishing-related caching. Just yesterday I published an updated business process (for another customer) and the changes just did not want to show up on the form. Somehow, a couple of hours later, it worked.

    I guess I give it some time and check back later.

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: 'opportunity' entity doesn't contain attribute with Name

    Hi,

    It seems like a crm issue and I have seen few thread now where CRM is not able to find the fields which actually exists.

    Check this thread: community.dynamics.com/.../857035

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans