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 :
Customer experience | Sales, Customer Insights,...
Answered

Change actual revenue calculation opportunity close

(0) ShareShare
ReportReport
Posted on by

Hi!

A question related to the close opportunity. Microsoft have now made it possible to edit the Quick create form. But when I close an opportunity as won, the field Actual revenue in the close opportunity form is automatically populated with the value from the field Est.Revenue at the main form for opportunity. Is it a way to change this? I want the field on the eopportunity close dialog to take the value from the actual revenue field on the main opportunity form. I can not find a way to change this, it seems like everything is locked for editing.

Thank you in advance!

/Emma

I have the same question (0)
  • Verified answer
    LeoAlt Profile Picture
    16,331 Moderator on at

    Hi partner,

    It is possilbe to archieve your requirement by js code and here is the result.

    pastedimage1571908859630v1.png

    Just add the js function in the "onload" event of "OpportunityClose" entity "Qucik Create" form.

    pastedimage1571908937977v3.png

    pastedimage1571908909752v2.png


    function setActualRevenue(executionContext){
        var formContext = executionContext.getFormContext();
        //step1. get the entityX recordid by lookup field.
        var entityXRecord=formContext.getAttribute("opportunityid");
        if(entityXRecord!=null){
            var value=entityXRecord.getValue();
            //get the recordid
            var recordid=value[0].id;
            //get the option set field value on the entityX by web api
            Xrm.WebApi.retrieveRecord("opportunity",recordid,"?$select=actualvalue").then(
                function success(result) {
                    var filedvalue=result.actualvalue;
                    //set the value to field on entity Y
                    formContext.getAttribute("actualrevenue").setValue(filedvalue);
                },
                function error(error) {
                    Xrm.Navigation.openAlertDialog({ text: error.message });
                }
            );
        }
    }

    Hope it helps.

    Best Regards,

    Leo

  • EmmaCRMadmin Profile Picture
    on at

    Thanks a lot!

  • EmmaCRMadmin Profile Picture
    on at

    Hi again!

    We tried this today but realised that there must be some rule that the code crashes with. It still sets the value in actual revenue to value in estimated revenue in opportunity close form.

    We also tried to change event to "onsave" instead, when press save in the opportunity close as won we could see that the value chanages to the right value very fast and then is changed back to the wrong (estimnated rev) value.

    When looking in to the entity opportunity close, we looked at the relationships opportunity-opportunity close and could see that the mappings where not visible.

    Do you know how to work around this?

    Thanks in advanced!

  • Suggested answer
    Drew Poggemann Profile Picture
    4 on at

    Hi Emma,

    What about something more basic to fix the issue.  You could have the following:

    1.  Estimated Revenue - This could be the main field used for the Estimated Revenue throughout the opportunity process.  This field would be used until the Opportunity Business Process Flow is completed

    2.  Actual Revenue - When this value is populated setup a real time workflow that will take the value of the field of the Estimated Revenue and populate another field called "Original Estimated Revenue" and take the value of the Actual Revenue and populate the Estimated Revenue Field.  You could also do this second part through a business rule as well.

    This will allow the current "Estimated Revenue" to populate the "Actual Revenue" on the Opportunity Close process and provide you the value you expect.  You would also still have the Original Estimated Revenue for any reporting of Estimated to Actual.

    Just a thought on a different approach if you want to fill in the Actual Revenue before closing the Opportunity as won...

  • LeoAlt Profile Picture
    16,331 Moderator on at

    Hi partner,

    According to your description, there should be something effects the code. Please check if there is any workflow or busienss rule about opportunity and opportunity close.

    If you want to add a field mapping between opportunity and opportunity close, you should create a new 1:N relationship between opp and opp close.

    Best Regards,

    Leo

  • EmmaCRMadmin Profile Picture
    on at

    Hi!

    There are no business rules or workflows about opportunity and opportunity close that we have set up. We are not able to add a field mapping between the opportunity and opportunity close because it is not possible to choose opp close as related entity when we try to creare 1:N relationship. Microsoft has restricted that possibility.

    That is why i wonder if there is a way to work around their restrictions of this.

    Best Regards,

    Emma

  • Suggested answer
    Drew Poggemann Profile Picture
    4 on at

    Hi Emma, did you see my work-around suggestion because of these limitations?  Would that work for you?

  • Verified answer
    LeoAlt Profile Picture
    16,331 Moderator on at

    Hi partner,

    It's a very strange situation. The function worked well in my instance :-(

    Let's change another way, you could create a new custom field to store the correct Est.Revenue value, and map actual Revenue field with default Est.Revenue so that when you close the opportunity, the field actual revenue field on the opportunity close form will show the right value as you want.

    But it is really not a perfect solution, you could also raise a ticket to Microsoft Support Team to let the engineers check and try in your instance.

    Hope it helps.

    Best Regards,

    Leo

  • EmmaCRMadmin Profile Picture
    on at

    Hi,

    unfortuantly that was not a solution that would work for us, thank you anyway!

  • EmmaCRMadmin Profile Picture
    on at

    Thank you Leo!

    our developer looked in to it again and solved it by putting a time delay on the script. mabye not the best solution but it works for now.

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 74 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 31 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans