Apply a business logic to the Opportunity Close Quick Create form according to the context of the opportunity closure

In the release 2 2019, Microsoft introduced the ability to modify the Opportunity Close dialog using the Quick Create Form. In this blog, we will discuss the ability to apply a business logic to the Opportunity Close Quick Create form according to the context of the opportunity closure.

Use Case

Change the “Close Date” label depending on the context of the opportunity closure. Indeed, if we close the opportunity as won, we will display “Win date”. Otherwise, it will display “Lose date”.

Close as Won:

Close as Lost:

Solution

The context of the closure (Won/Lost) is stored in a parameter named “param_won”. This parameter is accessible from the data object of the page context input. This parameter “param_won” is a boolean which is equal to true in the case of closing a won opportunity and equal to false in the case of closing a lost opportunity.

Using this parameter, it will be possible to implement a logic depending on the context of the opportunity closure. The code below changes the label dynamically as described at the beginning of this blog.

function onLoad(executionContext){
var formContext = executionContext.getFormContext();
var pageContext = Xrm.Utility.getPageContext();
var isWon = pageContext.input.data.param_won;
if(isWon) formContext.getControl('actualend').setLabel('Win date');
else formContext.getControl('actualend').setLabel('Lose date');
}

This function should be executed when loading the OpportunityClose entity’s quick creation form.

Finally, this idea is discussed on the community.dynamics.com forum. You can read the discussion on this link.

One thought on “Apply a business logic to the Opportunity Close Quick Create form according to the context of the opportunity closure

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s