Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Auto excute Workflow when call method SaveChange() from plugin

Posted on by 40

Hi all,


When I custom plugin for CRM system.

I have a workflow send email notification for user or team when that record has been changed field Owner as image below:

68576.Capture1.PNG

After that I custom plugin (Post-Operation) change status (field Option Set Value) with some conditions and call CrmServiceContext with method SaveChange() as image 2 below:

6084401.Capture.PNG

When I do something to change field status. After refresh browser, status had been changed. Beside, the workflow "Email Notification Account" auto run.

Result: When I do something to change status, owner of that record will receive a email --> Spam Mail.

Anybody have solution to help me resolve this problem?

Thanks.

*This post is locked for comments

  • Son Dang Profile Picture
    Son Dang 40 on at
    RE: Auto excute Workflow when call method SaveChange() from plugin

    Hi Andrii Butenko,

    I had resolved that problem.

    Thanks a lot,

    Son Dang

  • Verified answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Auto excute Workflow when call method SaveChange() from plugin

    Hello,

    As for me the easiest way is to rewrite your code to use Late Binding and IOrganizationService using only fields that you really need to update like following:

    var currentAccount = new Entity("account", <account guid here>);

    currentAccount["tma_status"] = new OptionSetValue(latestProjectStatus);

    service.Update(currentAccount);

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,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans