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

Closing Multiple Opportunities with Power Automate

(0) ShareShare
ReportReport
Posted on by 30

I have recently migrated a load of dynamics data from one environment to another. In doing this, the opportunities I have migrated have all come across as open when they should've been in a closed as either Lost or Won state. Never the less, I now need to close all of these opportunities in bulk.

I've exported the opportunities and relevant data to excel and put that in a SharePoint list. I then set up a flow using the SharePoint list as the trigger with the following steps.

pastedimage1636023660139v5.png

The Update a Row step sets the Status, Status Reason, Actual Value and Actual Close Date

On running this I get the following error. 

pastedimage1636023599058v4.png

{
  "error": {
    "code""0x80040216",
    "message""This message can not be used to set the state of opportunity to lost. In order to set state of opportunity to lost, use the lost message instead.",
    "@Microsoft.PowerApps.CDS.ErrorDetails.HttpStatusCode""400",
    "@Microsoft.PowerApps.CDS.TraceText""[Microsoft.Dynamics.Sales.Plugins: Microsoft.Dynamics.Sales.Plugins.PreOpportunityUpdate]\r\n[a13c2831-776b-e611-80ec-00155dc14c00: Update of opportunity]\r\nEntered Microsoft.Dynamics.Sales.Plugins.PreOpportunityUpdate.Execute(), Correlation Id: c26fd127-3ae8-480f-aef1-d4998a1c0338, Initiating User: f2f84aac-8aa1-4e7f-bbe8-b309e14df767\r\nException: Microsoft.Dynamics.Solution.Common.CrmInvalidOperationException: This message can not be used to set the state of opportunity to lost. In order to set state of opportunity to lost, use the lost message instead. (Fault Detail is equal to Exception details: \r\nErrorCode: 0x80040216\r\nMessage: This message can not be used to set the state of opportunity to lost. In order to set state of opportunity to lost, use the lost message instead.\r\nStackTrace: \r\n   at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)\r\n   at System.Environment.get_StackTrace()\r\n   at Microsoft.Dynamics.Solution.Common.CrmException.BuildOrganizationServiceFault(Exception innerException, Int32 errorCode, Int32 statusCode, String message)\r\n   at Microsoft.Dynamics.Solution.Common.CrmException..ctor(String message, Exception innerException, Int32 errorCode, Int32 statusCode, Boolean isFlowControlException, Boolean enableTrace)\r\n   at Microsoft.Dynamics.Solution.Common.CrmException..ctor(String message, Exception innerException, Int32 errorCode, Int32 statusCode, Boolean isFlowControlException)\r\n   at Microsoft.Dynamics.Solution.Common.CrmException..ctor(String message, Exception innerException)\r\n   at Microsoft.Dynamics.Solution.Common.CrmInvalidOperationExc...)., Correlation Id: c26fd127-3ae8-480f-aef1-d4998a1c0338, Initiating User: f2f84aac-8aa1-4e7f-bbe8-b309e14df767\r\nExiting Microsoft.Dynamics.Sales.Plugins.PreOpportunityUpdate.Execute(), Correlation Id: c26fd127-3ae8-480f-aef1-d4998a1c0338, Initiating User: f2f84aac-8aa1-4e7f-bbe8-b309e14df767",
    "@Microsoft.PowerApps.CDS.InnerError.Message""This message can not be used to set the state of opportunity to lost. In order to set state of opportunity to lost, use the lost message instead."
  }
}

I'm basically making this up as I go along. I cant find much in the way of previous attempts of this, and what I have found is old Common Data Service blogs, which not longer work. 

Can someone help? I don't really understand the close process for Dynamics opportunities. So maybe I'm doing this incorrectly.

I have the same question (0)
  • Suggested answer
    Nya Profile Picture
    29,060 on at

    Hi,

    In order to close opportunities with Power Automate, you need to create an Opportunity Close Activity for each opportunity instead of just updating the opportunity records.

    Please refer to my answer to the following issue which contains how to create the activity.

    (+) When added to suppression list, close opportunity - Dynamics 365 Marketing Forum Community Forum

  • Suggested answer
    meelamri Profile Picture
    13,216 User Group Leader on at

    Hi,

    You can call "WinOpportunity" or "LoseOpportunity" actions using Dataverse perform bound action.

  • Suggested answer
    Nya Profile Picture
    29,060 on at

    Hi,

    If the issue has been solved, it would be appreciated if you could click "Yes" to verify my answer.

    Image

    If there is any further doubt, please do not hesitate to let me know.

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
Tom_Gioielli Profile Picture

Tom_Gioielli 137 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 57

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans