Tip #624: Updating won opportunity fields

When I receive an email from Mitch “Only in Texas” Milam with the subject “Well, this is interesting”, I know it will be just that. Last week was no exception:

Did you know (in 2015 at least) you can change the processed and staged fields on a Won Opportunity, without reopening it?

No, I didn’t know but a quick check later, yes, indeed, it is possible to update the fields on a closed opportunity:

// let's close an opportunity
var oppClose = new Entity("opportunityclose");
oppClose["opportunityid"] = opp.ToEntityReference();
oppClose["actualend"] = DateTime.Now;
oppClose["actualrevenue"] = new Money(42.00m);

var response = svc.Execute<WinOpportunityResponse>
    (new WinOpportunityRequest()
        OpportunityClose = oppClose,
        Status = new OptionSetValue(3)

// and then bump budget and estimates
var e = opp.GetAttributeValue<Money>("estimatedvalue");
var b = opp.GetAttributeValue<Money>("budgetamount");
var updOpp = new Entity("opportunity")
    Id = opp.Id
updOpp["estimatedvalue"] = new Money(e.Value + 1m);
updOpp["budgetamount"] = new Money(b.Value + 1m);

Here you have it. My guess is that this change in behavior is to support modifications of the fields inside the business process flows which may continue “running” regardless of the opportunity state and locking down the fields would break the processes.

15 thoughts on “Tip #624: Updating won opportunity fields

  1. What is also interesting, and very helpful, is that it is now easy for users to edit a Closed Opportunity view using the “Open in Excel Online” feature! I have a client who was struggling with duplicate “wins” showing up on a report because re-opening them created two Opportunity Close activities. This provided a simple solution to edit incorrect information previously entered when needed. Edit in the view and save and close it. Voila!

    • AdamV says:

      If you close and re-open a Case or Opportunity, the Case/Opp Close activity record remains there, but changes status to “Cancelled” (you have cancelled the closing of it, in other words). If you close it again you get a second close record which is completed. So you can see an “audit trail” of a record being closed, re-opened, re-closed, re-opened and finally closed, which can be helpful.
      I do find some people want/need to report on the close activities because they have extra information that does not get updated to the parent record. To avoid “double counting” just be sure to filter the report based on the status of the close activities.

  2. AdamV says:

    You have been able to edit closed opportunities using workflows since CRM 4.0, as far as I can recall.
    And as far as I know you could do this through code too, as well as data export / import. It is only the UI that the record appears to be read-only.

    Activities get locked down, Cases did not used to but now are also locked. Some other “special” sales transaction records (eg orders, invoices) and very locked down entities like Contracts are also unavailable for editing once they reach an inactive status.

  3. This is interesting, is it supported or not?!? The other day I found out you can add a new quote product view by adding quote products as a subgrid to a form and clicking the new button within the sub grid configuration page. You cannot create a new view within the usual entity view area though!

  4. Clement says:

    Thanks for your post,
    My question is the following, is it possible to edit money field for a closed opportunities so we can recalculate them with an historical exchangeRate value different than the one at the closing time ?
    If yes how should i proceed ?

    Thanks !

    • You can certainly change the money field value but I’m not 100% sure if closed opportunity is going to recalculate if you do so – something to test. If it does not recalculate, another option would be to try sending CalculateActualValueOpportunityRequest.

      • Clément says:

        Thanks for your answer George.
        In fact my problem here is different than yours :(.
        I know that we can recalculate the revenue field but since it’s the Base money field are always recalculated with the current exchange rate, it won’t help.
        I need to be able to “update” the exchange rate (field is read only, nice ..) and then with an update of the revenue field i want the revenue base field to be recalculated with the new exchange rate.
        I’m in migration process to crm online, and that’s my only blocking point before running everything fine 🙂

  5. Nice scripts … i need workflow with scripts, how to make its? where element SVC? but code is visual studio / plugin?

  6. Evan Watson says:

    Mitch, thank you for this tip! While I ended up using a workflow to update the fields post close your post “inspired” me. Thanks!

  7. Jennifer Grassan says:

    Thanks for post! I had just tested the workflow method on Activities, and no go for Closed. It does work for Closed “Won” Opportunities for my Option set field update, but not on the Closed “Lost” Opportunities. Has anyone run into that issue? Do I need to run code to update those?

  8. Timothy Dailey says:

    This is a great post, I was writing workflows to “reopen opportunity”, “copy fields from one to the other”, “reclose as won” – but then after reading this I just tried one record with the middle workflow (to update the opportunities) and it worked! I didn’t know you could update a read-only opportunity without re-opening.

    Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *