Asked by:
CRM 2011 RU13 - How to get form to update

Question
-
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
}
}
}
Wednesday, September 4, 2013 6:49 PM
All replies
-
You don't need to use setSubmitMode() if the field is not hidden
The following lines of code look like invalid
Xrm.Page.getAttribute("tas_nurtured").controls.get(0).setDisabled(true); //Disable field
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.
Wednesday, September 4, 2013 10:47 PM -
Use:-
Xrm.Page.ui.controls.get("tas_nurtured").setDisabled(true);
Regards Faisal
Thursday, September 5, 2013 7:32 AM -
I appreciate the replies so far, but nothing that addresses the problem I'm having. Anyone who can help?Wednesday, September 11, 2013 4:28 PM
-
Hi,
Try to change
if(NurturedYN == 1)
to
if(NurturedYN ==true)
Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.Wednesday, September 11, 2013 4:46 PMModerator -
Do the setSubmitMode("always") before setting the value. That's the only thing I see that could cause it.
Hope that helps,
Ray
Wednesday, September 11, 2013 6:21 PM