Thursday, 25 October 2018

How to Get Opportunity Won or Lost via JavaScript in Dynamic CRM.

Get Opportunity Won or Lost via JavaScript


Description:

In this example we explain that how to get Opportunity is Won or lost using JavaScript in Dynamic CRM.or how to get the Status of the Opportunity using JavaScript in Dynamic 365 CRM.or How to track Opportunity closed as won using JavaScript in Dynamic CRM.

In our requirement like when any Opportunity is open by user at that time we have to get the status of the Opportunity like it is Won Opportunity or Lost Opportunity so we have used one JavaScript function on Form Load of Opportunity and get the status of the Opportunity when Opportunity is open by end user.

So below is the JavaScript code that are used to get the Opportunity status like Won or Lost in Dynamic CRM.
JavaScript Function:

var statecode = TryParseInt(Xrm.Page.getAttribute('statecode').getValue(), null);
if (statecode != null)
{
 // Open
 if (statecode == 0)
 {
  // Do Something
 }
 // statecode 1 = Won
 else if (statecode == 1)
 {
  // Do Something
 }
 // statecode 2 = Lost
 else if (statecode == 2)
 {
  // Do Something
 }
 else
 {
  // Handle issue
 }
}


0 comments:

Post a Comment