Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

[Help] Flow to deactivate Opportunity when Account is deactivate

(0) ShareShare
ReportReport
Posted on by 40

Hello,

I am currently trying to create a process (with Flow in Power App) :

When an Account is deactivated, close all related opportunities (unless their status is Concluded) with
- status = Lost
- reason for status = Canceled

Here is:


1 / When a record is updated

pastedimage1578063080252v6.png

2 / List the opportunities associated with the account

pastedimage1578063088625v7.png

3 / Apply to everyone: Update status / reason for status

pastedimage1578063125587v8.png

pastedimage1578063125588v9.png

pastedimage1578063125589v10.png


Steps 1 and 2 work fine !

For step 3, I have the following error :

--batchresponse_ad515f98-6e21-4dde-af5e-07ca97783621
Content-Type: application/http
Content-Transfer-Encoding: binary

HTTP/1.1 400 Bad Request
REQ_ID: 1ce0f33e-530a-438f-bf2d-61257ddf8c02
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0

{"error":{"code":"0x80040216","message":"Ce message ne peut pas \u00eatre utilis\u00e9 pour d\u00e9finir l\u2019\u00e9tat de l'opportunit\u00e9 sur perdu. Pour d\u00e9finir l\u2019\u00e9tat de l'opportunit\u00e9 sur perdu, utilisez plut\u00f4t le message perdu.","innererror":{"message":"Ce message ne peut pas \u00eatre utilis\u00e9 pour d\u00e9finir l\u2019\u00e9tat de l'opportunit\u00e9 sur perdu. Pour d\u00e9finir l\u2019\u00e9tat de l'opportunit\u00e9 sur perdu, utilisez plut\u00f4t le message perdu.","type":"Microsoft.Dynamics.Solution.Common.CrmInvalidOperationException","stacktrace":" at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.Execute(OrganizationRequest request, InvocationContext invocationContext, CallerOriginToken callerOriginToken, WebServiceType serviceType, Boolean checkAdminMode, ExecutionContext executionContext, Dictionary`2 optionalParameters)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataExecutionContext.Upsert(Entity entity)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataExecutionContext.Update(Entity entity, UpdateOption updateOption)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataServiceDataProvider.UpdateEdmEntity(CrmODataExecutionContext context, String edmEntityName, String entityKeyValue, EdmEntityObject entityObject)\r\n at Microsoft.Crm.Extensibility.OData.EntityController.PatchEntityImplementation(String& entityName, String key, EdmEntityObject entityDelta)\r\n at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties)\r\n at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func`1 func)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"}}}
--batchresponse_ad515f98-6e21-4dde-af5e-07ca97783621--

pastedimage1578063184413v11.png

pastedimage1578063196502v12.png

This flow works fine to deactivate Contacts and Quotes related.

Please, I need some help to find an issue.

Thanks in advance !

  • Marcel Lathouwers Profile Picture
    Marcel Lathouwers 173 on at
    RE: [Help] Flow to deactivate Opportunity when Account is deactivate

    I'm trying to get this unbound action LoseOpportunity to work but no luck yet. It either fails during execution "use navigation properties instead" or when saving the flow with errors like ".... can not be converted to String/uuid"

    A screenshot of the parameters filled would be very helpfull

  • RomainH Profile Picture
    RomainH 40 on at
    RE: [Help] Flow to deactivate Opportunity when Account is deactivate

    Thank you very much, it answer the question :-)

  • RomainH Profile Picture
    RomainH 40 on at
    RE: [Help] Flow to deactivate Opportunity when Account is deactivate

    Hello,

    Thank you for your answer. I will try with the opportunity close entity.

    :-)

  • RomainH Profile Picture
    RomainH 40 on at
    RE: [Help] Flow to deactivate Opportunity when Account is deactivate

    Hello,

    The error message is : "This message cannot be used to set the opportunity status to lost. To set the opportunity state to lost, use the lost message instead."

  • Suggested answer
    Inogic Profile Picture
    Inogic 438 on at
    RE: [Help] Flow to deactivate Opportunity when Account is deactivate

    Hi Romain,

    The CDS (Current) connector now supports executing Actions through Flows as well. To get access to the CDS (Current) connector, you need to add the flow from within a solution at make.powerapps.com.

    Once you choose the CDS (Current) connector, you can choose Perform Unbound Action and for the Opportunity entity, you see the Win Opportunity and Lose Opportunity action. Choose the appropriate one to close all the opportunities. You can pass the values required for close date, value etc to this action itself.

    pastedimage1578292689361v1.png

    HTH

    ~roohi

  • Verified answer
    cloflyMao Profile Picture
    cloflyMao 25,202 on at
    RE: [Help] Flow to deactivate Opportunity when Account is deactivate

    Hi Roman,

    Close opportunity action would be special compared with deactivating other entities.

    You can create opportunity close entity records and assoicate them with listed opportunities, which will trigger an hidden system action to close their parent opportunities.

    Overview of flow:

    I added an extra check condition: Status Value(statecode) equals 1 -> when an account is set to inactive.

    pastedimage1578277704033v1.png

    Detail of the create new opportunity close action:

    pastedimage1578277882994v2.png

    Result 1:

    Deactivated account with its related closed opportunities.

    pastedimage1578277958330v3.png

    Result 2: 

    Automatically created opportunity close records.

    (You should add parent opportunity field to form manually)

    pastedimage1578278064110v4.png

    Regards,

    Clofly

  • a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: [Help] Flow to deactivate Opportunity when Account is deactivate

    Hello,

    I don't speak or read French (correct me if it's not French) so can you please translate error message?

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans