Hey everyone,
GOAL:
I have a function thats triggered on the change of a two option set.
If the user sets the value to false, they receive a prompt asking them for the reason behind this. If the user cancels or enters nothing. the field is set back to true.
ISSUE:
the value of gg_markfordeactivation will only ever be set back to true if the mouse hovers over the field.
this also cause issues with the prompt entering a random never ending loop sometime. please help me here.
here is the code, line 25 is where the issue starts
function contactCancelationReason(executionContext) {
'use strict';
var formContext = executionContext.getFormContext(),
mfdLogicalName = "gg_markfordeactivation",
mfdField = formContext.getAttribute(mfdLogicalName),
mfdValue = mfdField.getValue();
// check to see if the field exists
if (mfdField !== null) {
// checks if mfd was set to false
if (mfdValue === 0) {
// pop to ask for reason
var reason;
reason = prompt("Please decribe the reason why this record is not to be deleted...");
// checks if a reason was enterd
if (reason !== "null" || reason !== null || reason !== "") {
// yes, send http request to create a note
} else {
// no, set mfd back to true
Xrm.Page.getAttribute(mfdLogicalName).setValue(true);
return;
}
}
}
}