web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

Opportunity record does not get auto refreshed after it closed.

(3) ShareShare
ReportReport
Posted on by 10
Opportunity record does not get auto refreshed after it closed. How to achieve this ?
I have the same question (0)
  • Suggested answer
    Daivat Vartak (v-9davar) Profile Picture
    7,827 Super User 2025 Season 2 on at
    Opportunity record does not get auto refreshed after it closed.
    Hello CU16040836-0,
     

    ou're right, by default, Dynamics 365 Sales Opportunity records might not automatically refresh their display immediately after they are closed. This can be inconvenient as users might see outdated status or other fields until they manually refresh the page.

    Here are several ways to achieve automatic refreshing of the Opportunity record after it's closed, ranging in complexity:

     

    1. Using a Real-time Workflow (Simplest Configuration):

    This is often the easiest and most common approach for simple refresh scenarios.

    • Go to Settings > Processes.

    • Click New.

    • Process Name: Give it a descriptive name (e.g., "Auto Refresh Opportunity on Close").

    • Category: Choose Workflow.

    • Entity: Select Opportunity.

    • Type: Choose Real-time.

    • Uncheck Run this workflow in the background.

    • Click OK.

    • Add a Step: Click Add Step and select Update Record.

    • In the "Set Properties" for the Update Record step:

      • In the "Look For" dropdown, select Opportunity (Regarding).

      • In the "Set Values" section, you don't actually need to change any values. The act of performing an update will trigger a refresh of the form. You can optionally update a field like "Modified On" to ensure a change occurs.

      • Click Save and Close. 

    • Add a Condition (Optional but Recommended): You might want to only trigger this refresh when the Opportunity's status changes to "Won" or "Lost".

      • Click Add Step and select Check Condition.

      • Configure the condition to check if the Status Reason field of the Opportunity equals your "Won" or "Lost" status reason values.

      • Move the "Update Record" step under the "True" branch of the condition.

      •  

    • Configure Workflow Execution:

       

      • Under Start when, check the Record status changes option.

      • Select the Status field and choose the values corresponding to "Won" and "Lost".

    • Save and Activate the Workflow.

    How it Works: When the Opportunity's status changes to "Won" or "Lost", this real-time workflow will trigger and perform a self-update on the record, forcing the browser to refresh and display the updated status and other field changes.

     

    2. Using a JavaScript Web Resource (More Control, Requires Code):

    This method provides more control over the refresh behavior and can be triggered on specific events.

    • Create a JavaScript Web Resource:

      • Go to Settings > Customizations > Customize the System > Web Resources.

      • Click New.

      • Give it a Name (e.g., OpportunityCloseRefresh.js).

      • Display Name: A user-friendly name.

      • Type: Select Script (JScript).

      • In the Text Editor, add the following JavaScript code:

      • function refreshOpportunityForm(executionContext) {

          var formContext = executionContext.getFormContext();
          formContext.data.refresh(false).then(function () {
              // Optional: Add any post-refresh logic here
              console.log("Opportunity form refreshed after close.");
          }, function (error) {
              console.error("Error refreshing form:", error);
          });
      • }

      •  

    • Attach the Web Resource to the Opportunity Form:

      • Go to Settings > Customizations > Customize the System > Entities > Opportunity > Forms.

      • Open the Main form (or the relevant form).

      • Go to the Form Properties.

      • In the Form Libraries section, click Add and select the OpportunityCloseRefresh.js web resource you created.

      • Go to the Events tab.

      • In the Event Handlers section, click Add.

      • Event: Select OnSave.

      • Function: Enter refreshOpportunityForm.

      • Check the Pass execution context as first parameter option.

      • Execution Context: Choose Stage and select On Save as Out.

      • Add a Condition (Optional but Recommended): You can add a condition to only execute this script when the statuscode (Status Reason) field changes to "Won" or "Lost". 

    • Save and Publish Your Customizations.

       

    How it Works: When the Opportunity form is saved and the status reason changes to "Won" or "Lost", the refreshOpportunityForm JavaScript function will be executed, forcing a data refresh of the form. The false parameter in formContext.data.refresh(false) indicates that only the data should be refreshed, not the entire page.

     

    3. Using a Power Automate Flow (More Flexible for Complex Scenarios):

    Power Automate offers more flexibility for complex actions that might need to occur after closing the Opportunity, including a refresh.

    • Create a new Flow (Automated Cloud Flow).

       

    • Trigger: Choose the "When a record is created, updated, or deleted" trigger for the Opportunity entity.

    • Scope: Select Organization.

    • Trigger Conditions (Crucial): Add a condition to only trigger when the Status Reason field changes to your "Won" or "Lost" values. You can use a condition like:
      _statusreason_value Changes

      And then add another condition to check if the new value is one of your closed status reasons.


    • Action: Add a "Perform a bound action" action for the Opportunity entity.

    • Action Name: Choose "RefreshRecord".

    • Record ID: Use the Opportunity (Regarding) dynamic content from the trigger.

    • Save and Activate the Flow.

    How it Works: When the Opportunity's status reason is updated to "Won" or "Lost", the flow will trigger and execute the RefreshRecord bound action, which will signal the client application to refresh the form.

     

    Choosing the Right Approach:

    • For a simple refresh on status change, a Real-time Workflow is often the easiest to configure.

    • If you need more control over when the refresh occurs or want to perform additional client-side actions after the refresh, JavaScript provides more flexibility.

    • For more complex scenarios involving other integrations or actions beyond a simple refresh, Power Automate offers the most powerful and flexible solution.

    •  

    Remember to test your chosen solution thoroughly after implementation to ensure it works as expected in your Dynamics 365 environment.

     
    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more. If you have further questions, please feel free to contact me.
     
    My response was crafted with AI assistance and tailored to provide detailed and actionable guidance for your Microsoft Dynamics 365 query.
     
    Regards,
    Daivat Vartak
  • Suggested answer
    Tom_Gioielli Profile Picture
    2,020 Super User 2025 Season 2 on at
    Opportunity record does not get auto refreshed after it closed.
    Ah, got it.
     
    If it isn't happening automatically, you could probably force it with a relatively simple JavaScript function. I'm not a developer, and CoPilot gave me the following script (so I can't vouch for the accuracy).
     
    Have it trigger or set to run when [Actual Close Date] is updated on the Opportunity, and that should hopefully run as soon as the Opportunity Close action is completed without requiring a manual refresh.
     
    function refreshPage() {
        Xrm.Page.data.refresh(true); // Pass 'true' to save changes before refreshing
    }
  • Holly Huffman Profile Picture
    6,518 Super User 2025 Season 2 on at
    Opportunity record does not get auto refreshed after it closed.
    Good morning, afternoon, or evening depending on your location!
     
    • Are you referring to the UI not refreshing after closing the Opportunity, or is the issue related to data updates not appearing immediately in views or reports?
    • Is there any automation, workflow, or integration involved that should trigger upon closing the Opportunity?
  • CU16040836-0 Profile Picture
    10 on at
    Opportunity record does not get auto refreshed after it closed.
    @Tom_Gioielli Thanks for your response. What I meant was after clicking the 'Close As Won' button, the "opportunity close" quick create form will be loaded. Once I filled the fields on the opportunity close quick create form and save it, the opportunity that we closed doesn't get updated spontaneously. (i.e. the message "Read-only This record’s status: Won" on the top of the opportunity name was not showing immediately) I have to refresh manually inorder to see that message. I wish to auto refresh after the opportunity get closed.
  • Tom_Gioielli Profile Picture
    2,020 Super User 2025 Season 2 on at
    Opportunity record does not get auto refreshed after it closed.
    Can you provide some more information? What do you mean by refreshing after closed? Is there some automation or other action you are expecting to occur after saving a change to the record?

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…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Hamza H Profile Picture

Hamza H 141

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 132

#3
DAnny3211 Profile Picture

DAnny3211 130

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans