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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Service.update() for a Post-Operation Update Message plugin; not working

(1) ShareShare
ReportReport
Posted on by 3,755

I created a plugin; Post-Operation (40) on the Update Message.

I make my changes that are valid to a single field (Replace a value with 100).

When the record is saved, the field is not updated, so I added the line:

service.update(account);

But this gives me a Plugin error.

How should I save changes on the Update Message of a Post-Operation plugin?

*This post is locked for comments

I have the same question (0)
  • Royal King Profile Picture
    27,686 on at

    Rather than using plugin why can't use real-time workflow on the same update event. If you have to use plugin post complete code that may help to figure out the issue.

  • Hussman Profile Picture
    3,755 on at

    Edit: I don't want to use Pre-Operation. I need to it occur Post-Operation.

  • Hussman Profile Picture
    3,755 on at

    Hi, my code works - I just want to know how to update the record in Post-Operation.

  • Royal King Profile Picture
    27,686 on at

    it's happening because your plugin is executed when a record is updated and  your code updates the record again, this cause to call again the plugin ...

    Then you have your infinite loop

    You can prevent the loop using the IExecutionContext.Depth property

    msdn.microsoft.com/.../microsoft.xrm.sdk.iexecutioncontext.depth.aspx

  • Verified answer
    SyedHussain Profile Picture
    1,820 on at

    This will solve your problem:

                   if (context.Depth <= 1)

                   {

                       service.Update(account);

                   }

  • Hussman Profile Picture
    3,755 on at

    Thanks, that worked.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans