I want to show a "Confirm" message on the OnChange event for a bit field when "Yes" is selected. The event is firing and I can see my "Confirm" message. However, if I click "Cancel" on the Confirm message then I have to click "No" before I can effectively click "Yes" again. (If I click "Yes" after clicking "Cancel" the form appears to save, but does not actually save. And my "Confirm" message does not appear the second time as it should.)
Here is my code:
function ConfirmNurtured ()
{
var NurturedYN = Xrm.Page.data.entity.attributes.get("tas_nurtured").getValue(); //Get value
if(NurturedYN == 1) //If choice = Yes
{
//Make "Nurtured by Chris" enabled or disabled, depending on response-------------------------------
var Response = confirm("Once this opportunity has been changed to a nurtured status, it cannot be changed back. If you want to continue, press OK.");
if(Response) //If User clicks OK
{
Xrm.Page.getAttribute("tas_nurtured").setSubmitMode("always"); //Submit
Xrm.Page.getAttribute("tas_nurtured").controls.get(0).setDisabled(true); //Disable field
}
else //If User clicks Cancel
{
Xrm.Page.getAttribute("tas_nurtured").setValue(0); //Set value to No
Xrm.Page.getAttribute("tas_nurtured").setSubmitMode("always"); //Submit
}
}
}