Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

Updating a custom field in Entitlement from a plugin

Posted on by 7

Hi

I have a plugin in C# that updates Entities during the creation process. This is working just fine except for Entitlements.

I update a custom field on the Entitlement:

entity.Attributes[fieldName] = "some value";

_dynamicsOrganizationService.Update(entity);

This throws the following error:

"You can't deactivate an entitlement when it's in the draft state."

I don't get it! The statecode and statuscode are both 0 ("Draft")

So for some reason Dynamics thinks I am trying to deactivate the entitlement entity when I am updating it.

Any help on this matter i appreciated!

-Peter-

  • Verified answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: Updating a custom field in Entitlement from a plugin

    Glad that it worked.

    Please mark my answer verified by select yes in Did this answer your questions?

  • Suggested answer
    Badblock Profile Picture
    Badblock 7 on at
    RE: Updating a custom field in Entitlement from a plugin

    YES! That worked! Thank you so much!

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: Updating a custom field in Entitlement from a plugin

    Hi,

    You should create new object of Entity and then use this object to pass in service.update

    Some like this

    Entity entitlementObject=new Entity("Entitlement Entity Schema Name");

    entitlementObject.Id=Entitlement Record ID;

    entitlementObject.Attributes[fieldName] = "some value";

    _dynamicsOrganizationService.Update(entitlementObject);

    Let me know if it works.

    Please mark my answer verified if i were helpful

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

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,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans