Skip to content

Instantly share code, notes, and snippets.

@azec-pdx
Created January 6, 2016 00:27
Show Gist options
  • Select an option

  • Save azec-pdx/ecf4b7da4384ca165969 to your computer and use it in GitHub Desktop.

Select an option

Save azec-pdx/ecf4b7da4384ca165969 to your computer and use it in GitHub Desktop.
CRM refresh form and alert when field changed
var originalBlastStatus = null;
function SaveAndRefresh() {
//Xrm.Page.getAttribute("myAttributeName").setValue(null);
//Xrm.Page.data.refresh(true);
originalBlastStatus = Xrm.Page.getAttribute("new_campaign_status").getText();
checkStatusChanged();
}
var checkStatusChanged = function () {
//Always refresh, and then get new value to match...
Xrm.Page.data.refresh(false);
var afterRefreshBlastStatus = Xrm.Page.getAttribute("new_campaign_status").getText();
var condition = (originalBlastStatus == afterRefreshBlastStatus) ? false : true;
if (condition) {
alert("Blast status was updated!");
}
else {
setTimeout(checkStatusChanged, 1000); // check again in a second
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment