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 :
Customer experience | Sales, Customer Insights,...
Suggested Answer

OpportunityWin Error in Microsoft.Dynamics.Sales.Plugins

(0) ShareShare
ReportReport
Posted on by 76

I manually coded via a Workflowaction the close Opportunity. 

The LoseOpportunityRequest works as expected and the opportunity is closed and a opportunityclose-Entity is created and I can see it in the activity-pane of the opportunity.

But if I call a WinOpportunityRequest I get the following error:

System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: An unexpected error occurred. (Fault Detail is equal to Exception details:
ErrorCode: 0x80040216
Message: An unexpected error occurred.;
[Microsoft.Dynamics.Sales.Plugins: Microsoft.Dynamics.Sales.Plugins.PreOperationOpportunityWin]
[aGuid....: Pre-operation on win of opportunity]
Entered Microsoft.Dynamics.Sales.Plugins.PreOperationOpportunityWin.Execute(), Correlation Id: Id A, Initiating User: UserId
Exiting Microsoft.Dynamics.Sales.Plugins.PreOperationOpportunityWin.Execute(), Correlation Id: Id A, Initiating User: UserId

StackTrace:
at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)
at Microsoft.Crm.Extensibility.PipelineInstrumentationHelper.Execute(Boolean instrumentationEnabled, String stopwatchName, ExecuteWithInstrumentation action, PipelineExecutionContext context)
at Microsoft.Crm.Extensibility.Pipeline.<>c__DisplayClass2_1.<Ex...).

No custom Plugin from our side is registered on opportunity or opportunityclose.

The ootb-CloseDialog works as expected.

any hints?

©a-x-i

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    According to the stack trace code error is caused by OOB Sales Plugin - Microsoft.Dynamics.Sales.Plugins.PreOperationOpportunityWin.Execute.

    There are 2 ways to find the reason:

    1. You can check the API call that happens when a user closes the opportunity and compare it to your WinOpportunityRequest - and locate what's missing.

    2. You can download Microsoft.Dynamics.Sales.Plugins library from Dynamics (for example using Assembly Recovery tool from XrmToolBox) and open it using ILSpy or .Net Reflector and analyze the code to find what's missing.

  • Axi Bachlechner Profile Picture
    76 on at

    Thank you. You lead me in the right direction. After checking the payload I controlled the code of the workflowaction and saw that I did this wrong:

    winRequest.OpportunityClose = opportunity;

    but should look like this:

    winRequest.OpportunityClose = opportunityClose;

    So I set the wrong entity.

    Some dirty copy/paste error :(

    a-x-i

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    If my reply (or replies) answers your question take a minute and verify the answer. You can do it by clicking "Yes" at the top of the reply (or replies) under the label "Does this answer your question?"

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 > Customer experience | Sales, Customer Insights, CRM

#1
Pallavi Phade Profile Picture

Pallavi Phade 98

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 60 Super User 2025 Season 2

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 43 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans