Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Update the Opportunity Stage in ASP.NET

(0) ShareShare
ReportReport
Posted on by 44

Hi all,

I'm having some problems with the updating of the value of the stages of an Opportunity.

I' m following the sample here: https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/sample-work-business-process-flows

Here's the code

 activeStageId = (Guid)pathResp.ProcessStages.Entities[activeStagePosition   1].Attributes["processstageid"];

// Retrieve the process instance record to update its active stage
ColumnSet cols1 = new ColumnSet();
cols1.AddColumn("activestageid");
Entity retrievedProcessInstance = crmSvc.Retrieve(procInstanceLogicalName, processOpp1Id, cols1);

// Update the active stage to the next stage
retrievedProcessInstance["activestageid"] = new EntityReference(ProcessStage.EntityLogicalName, activeStageId);
crmSvc.Update(retrievedProcessInstance);

// Retrieve the process instance record again to verify its active stage information
ColumnSet cols2 = new ColumnSet();
cols2.AddColumn("activestageid");
Entity retrievedProcessInstance1 = crmSvc.Retrieve(procInstanceLogicalName, processOpp1Id, cols2);

EntityReference activeStageInfo = retrievedProcessInstance1["activestageid"] as EntityReference;
if (activeStageInfo.Id == activeStageId)
{
    activeStageName = activeStageInfo.Name;                   
}

By the way, I'm having at least 2 problems:

1. The ProcessStage class, gives me an error, and I don't know how should I fix;

2. the method: crmSvc.Retrieve(procInstanceLogicalName, processOpp1Id, cols1); gives me an exception: System.ServiceModel.FaultException`1

Thanks for any helps.

  • RE: Update the Opportunity Stage in ASP.NET

    Hi,

    Have you tried this function for different records and different business process flows ?

  • Ryuzaki53 Profile Picture
    Ryuzaki53 44 on at
    RE: Update the Opportunity Stage in ASP.NET

    Hello,

    before that, suddenly an error appeared, in the same method i posted below, the line is:

    RetrieveActivePathResponse pathResp = (RetrieveActivePathResponse)crmSvc.Execute(pathReq);

    The message error:

    An unexpected error occurred.

    The stack trace:


    Server stack trace:
    in System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
    in System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
    in System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
    in System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

    Exception rethrown at [0]:
    in Microsoft.Xrm.Tooling.Connector.CrmServiceClient.Execute(OrganizationRequest request)
    in WebService.Controllers.AccountsController.DetailsOpp(Nullable`1 id, Boolean flag) in C:\Users\...\source\repos\WebService\WebService\Controllers\AccountsController.cs:riga 216

    Hope someone can help me solving this, it was working before, but suddenly this happened...

  • RE: Update the Opportunity Stage in ASP.NET

    Hello,

    Could you share more details about the errors that you are getting ? The stack trace or a screenshot ?

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,432 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans