Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Answered

SetState in PostUpdate plugin

Posted on by Microsoft Employee

Hi , guys ! I have question. Can I use SetState in PostUpdate plugin of entity ? May be a problems from that ? Thanks

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: SetState in PostUpdate plugin

    Thank you very much !

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: SetState in PostUpdate plugin

    Thanks

  • Verified answer
    Bipin D365 Profile Picture
    Bipin D365 28,960 Super User on at
    RE: SetState in PostUpdate plugin

    Hi,

    You don't need to use setstate if you want to change status of the record from post update plugin. You can simply add the field in entity object and use service.update to change record status.

    please see below link for more details.

    docs.microsoft.com/.../entity-operations-update-delete

    Please mark my answer verified if i were helpful

  • cloflyMao Profile Picture
    cloflyMao 25,194 on at
    RE: SetState in PostUpdate plugin

    Hi aleenav,

    Do you want to trigger the plugin on activation/deactivation of entity to update the entity field data?

    If so, yes, we can use SetState message  in PostOperation stage, and registration to SetStateDynamic  stage is also required.

    That because  both messages perform the same action in CRM and  as there is no typical thumb rule  for which action SetState/SetStateDynamic  message is fired, its better to register the plugin for  both messages  so that  our plugin works properly.

    pastedimage1609487978599v2.png

    Here is sample code for the plugin and I ran it successfully in my Dynamics 365 online environment.

    http://burnignorance.com/ms-crm-app-development-tips/plugin-for-setstate-message/

    In addition, here is another article about SetState message behavior:

    https://nishantrana.me/2018/07/11/when-does-the-plugin-registered-on-setstate-message-fires-in-dynamics-365/

    Regards,

    Clofly

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,989 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,588 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans