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 :
Microsoft Dynamics CRM (Archived)

Reopen lost/won opportunity using C# without mentioning specific Opportunity StatusReason

(0) ShareShare
ReportReport
Posted on by 277

Hello

I'm working on a plugin which needs to update opportunity field, but before updating the opportunity record I'm checking if the opportunity is open, if not I need to reopen it ( like we reopen it manually using ribbon button) without mentioning the status reason as there is another process which changes manually reopened opportunity's status reason.

if (IsOpportunityClosed(opportunityRef.Id, localcontext))

{
 /* Reopen the Opportunity record */
 SetStateRequest openOpp = new SetStateRequest();
 openOpp.EntityMoniker = opportunityRef;
 openOpp.State = new OptionSetValue(0);
 openOpp.Status = new OptionSetValue(100000044);
localcontext.OrganizationService.Execute(openOpp);
                                       
}


In, above code I'm using 100,000,044 as status. I'm wondering is there a way to reopen Opportunities without setting value of Status? Thanks in advance.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    ashlega Profile Picture
    34,477 on at

    Hi,

     It has to know the status - those two fields are connected.. there are different statuses per state..if you only update the state, it won't match the status anymore, so the whole request will fail

  • Turbo Forms Profile Picture
    277 on at

    Hi Alex thanks for replying. Is there any other way to reopen an opportunity ?

  • ashlega Profile Picture
    34,477 on at

    You are trying to ask the same question differently:)) I don't think there is any other way. Whether it's closed or active is all about the "state" field. Each state has a unique set of statuses. If you change state, you have to specify which status it's going to be.

  • Turbo Forms Profile Picture
    277 on at

    What I mean to say is , the Reopen Opportunity ribbon Button can open a closed opportunity without worrying about status.

  • ashlega Profile Picture
    34,477 on at

    That button is using javascript, so it might simply be passing default status id to the same request.

    Either way, Status is a required field, according to this:

    msdn.microsoft.com/.../microsoft.crm.sdk.messages.setstaterequest.aspx

    What I am wondering about, though, is why is this causing a problem at all?

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 > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans