To show dialog box in current entity

Dialog box in current entity

If Opportunity is won then show alert box and two buttons "yes or no", if "yes" then get current accountid and open account form. else if "no" then no action taken.

to check whether the Opportunity is won or loss.

function showConfirmDialog() {
debugger;
var statecode = Xrm.Page.getAttribute('statecode').getValue();
//alert(statecode);
if (statecode != null)
{
 // Won
 if (statecode == 1)
  {
     alert("won");
  }
else if(statecode == 2)
 {
   alert("Lost");
 }
 }
}

To perform action based on statecode.
function showConfirmDialog() {
debugger;
var statecode = Xrm.Page.getAttribute('statecode').getValue();
//alert(statecode);
if (statecode != null)
{
 // Won
 if (statecode == 1)
 {
  //alert(statecode);
    Xrm.Utility.confirmDialog("Click Yes or No to set the Personal Notes Value",
        function() {
            //alert("yes");
var currentaccid= Xrm.Page.getAttribute("parentaccountid").getValue()[0].id;
var currentaccname=Xrm.Page.getAttribute("parentaccountid").getValue()[0].name;
//alert(currentaccid);
//alert(currentaccname);
Xrm.Utility.openEntityForm( "account" , currentaccid);
//Xrm.Page.getAttribute("description").setValue("Yes");
        },
        function() {
           // Xrm.Page.getAttribute("description").setValue("No");
   });
 }
}
}

No comments:

Post a Comment