web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Single update to "statecode" and a regular field results in 2 separate Update plugin runs, both containing "statecode".

(0) ShareShare
ReportReport
Posted on by

We have recently migrated to CRM 2016 SP1 from CRM 2015. We have read that in the new version SetState requests are starting to be deprecated and that it is advised to use Update requests instead. According to the documentation if you send an Update request including a state/status fields and some regular fields, your update plugins should fire twice: once for the state/status fields and then for the regular fields.

However, what we've observed on several of our entities is that in such a scenario, an update plugin is indeed fired twice, but the attributes in the Target don't match the documentation. One run contains state/status fields only (and some additional fields like id and modifiedby, that were not part of the update) and second one contains ALL of the fields that were included in the update (including state/statecode).

This is not according to the documentation and we have plugins fired twice for state/statuscode fields and there's no way to differentiate if a certain request has already been handled. This breaks a lot of our custom code.

Here's an example:

var record = new Entity("affiliation");
record.Id = new Guid("889D5442-6719-E411-RW94-005056817123");
record["statecode"] = new OptionSetValue(1);
record["statuscode"] = new OptionSetValue(125080000);
record["name"] = "abc 01";
svc.Update(record);

Pre-operation plugin runs' attributes:

- first: statecode, statuscode, name, modifiedby, modifiedon, modifiedonbehalfby, affiliationid

- second: statecode, statuscode, modifiedby, modifiedon, modifiedonbehalfby, affiliationid

I haven't found anyone complaining about such a behaviour over the internet and I'm wondering if this is by design or a known bug of CRM or has it only happened to us? Or does it have something to do with SP1? We wouldn't like to invest in workarounds if this is something that can be/will soon be fixed.

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at
    RE: Single update to "statecode" and a regular field results in 2 separate Update plugin runs, both containing "statecode".

    Still happening on CRM OnPremise 8.2.1.176

  • Hoek Profile Picture
    on at
    RE: Single update to "statecode" and a regular field results in 2 separate Update plugin runs, both containing "statecode".

    Still having the issue that the plugin fires twice in D365 online. We are on the latest version of D365

  • DavidBerry Profile Picture
    on at
    RE: Single update to "statecode" and a regular field results in 2 separate Update plugin runs, both containing "statecode".

    Eric, our environments are Office 365, so the update was applied by Microsoft very recently.  It should be noted that, for us, this was a forced update.

  • Community Member Profile Picture
    on at
    RE: Single update to "statecode" and a regular field results in 2 separate Update plugin runs, both containing "statecode".

    Dave how did you download the update?  The download link in the KB says the files are not available for download.  Is there a link you can provide?

  • JohnAnonymous Profile Picture
    5,241 on at
    RE: Single update to "statecode" and a regular field results in 2 separate Update plugin runs, both containing "statecode".

    Good to hear it's fixed. Did not have the opportunity yet to test it myself.

  • Suggested answer
    DavidBerry Profile Picture
    on at
    RE: Single update to "statecode" and a regular field results in 2 separate Update plugin runs, both containing "statecode".

    Folks, I have returned to say that as of 8.1.1 (CRM 2016 Service Pack 1 Update 1), this issue appears to be fixed.  The fix was not in the release notes found here: https://support.microsoft.com/en-us/help/3203310/update-0.1-for-microsoft-dynamics-crm-2016-service-pack-1

    I'd assume that the fix is also contained in the 8.2.1 (Dynamics 365 Update 1), as they were released in the same timeframe.

    One issue I have additionally discovered, though, as a side-effect of this fix:  Workflows no longer fire on the "status change" trigger when using SetStateRequest.  This was a work-around for us, in light of this bug, and I'm having to scramble some hot-fixes into our Production environment to return to our original implementation of using Update for statecode/statuscode changes.

    Another key thing to note, is that the documentation is further out of date, because the Update message now contains all fields, and there is no secondary event for just the statecode/statuscode fields.  This actually makes the implementation of a plugin much easier, and straightforward--in my opinion.  But, this behavior doesn't appear to be properly documented.

  • JE-14021252-0 Profile Picture
    50 on at
    RE: Single update to "statecode" and a regular field results in 2 separate Update plugin runs, both containing "statecode".

    We are on 8.2.0.788 and are still seeing something similar.

    Confusingly, we have found different behaviour between a transition fired from inside a plugin and fired from a command button via the REST API.

    The working solution we have at present is:

    • target workflow is triggered on update of statuscode
    • plugin trigger uses legacy SetStateRequest
    • command button calls PATCH on REST API
  • Suggested answer
    JohnAnonymous Profile Picture
    5,241 on at
    RE: Single update to "statecode" and a regular field results in 2 separate Update plugin runs, both containing "statecode".

    Mentioned earlier in this thread, the issue is still there in the last update of CRM. It will most likely be fixed with the next verions of CRM, version 9, probably this spring.

  • nwood2009 Profile Picture
    25 on at
    RE: Single update to "statecode" and a regular field results in 2 separate Update plugin runs, both containing "statecode".

    Is there any news on this? I am still getting this issue

  • Suggested answer
    razdynamics Profile Picture
    17,308 User Group Leader on at
    RE: Single update to "statecode" and a regular field results in 2 separate Update plugin runs, both containing "statecode".

    We have the same issue when using setstate with Webapi, so we had to create a Custom Field and update that instead, and use a workflow to update the correct status accordingly.

    Thanks Martin, Great to know that im not the only one facing this issue, and fix will be released in next major release

    Best Wishes, Raz

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans