Quantcast
Channel: Alert.js - CRM 2013-2016 Custom Alerts and Popup Dialogs JavaScript Lightbox
Viewing all articles
Browse latest Browse all 170

Commented Unassigned: Alert.js Not Working In ONSAVE Method [717]

$
0
0
hi. I use Microsoft Dynamic CRM 2016 on-Premise. I Use Alert.js Lib in OnSave Method To Call and Get Response from current User That Loged into the CRM. But It Is Not Working. Please Help Me.
When Call The Alert.Show It Is Not Working After Save Process Completed It Show To Me Dialog With Two Button. I Want To Prevent Save. :(

My Code:

function Onsave(econtext) {
var NewFeature = Xrm.Page.getAttribute("eit_featuregroup").getValue();
Newstatus = Xrm.Page.getAttribute("statuscode").getValue();
if (FormType == 2) {
if (Newstatus == 915840011 || Newstatus == 915840012) {
NewTeam = RetrieveTeam(NewFeature[0].id);
}
}

if (NewTeam != CurrentTeam) {
TeamChangeconfirm(econtext);
}
}


function TeamChangeconfirm(econtext) {
Alert.show("This Function Is Go", null, [
new Alert.Button("Yes", null, true, false),
new Alert.Button("No", function () {
preventSave(econtext);
Alert.show("It Is Not Save", null, [new Alert.Button("Close", null, true, false)], "INFO", 500, 200);
}, true, false)
], "QUESTION", 500, 200);
}

function preventSave(econtext) {
var eventArgs = econtext.getEventArgs();
var SaveMode = eventArgs.getSaveMode();
if (SaveMode == 70 || SaveMode == 2 || SaveMode == 1) {
eventArgs.preventDefault();
}
}
Comments: ** Comment from web user: Liger **

Something like this "should" work:

```
var _autoFired = false;
function Onsave(econtext) {
if (_autoFired) { _autoFired = false; return; }

var NewFeature = Xrm.Page.getAttribute("eit_featuregroup").getValue();
Newstatus = Xrm.Page.getAttribute("statuscode").getValue();
if (FormType == 2) {
if (Newstatus == 915840011 || Newstatus == 915840012) {
NewTeam = RetrieveTeam(NewFeature[0].id);
}
}

if (NewTeam != CurrentTeam) {
TeamChangeconfirm(econtext);
}
}


function TeamChangeconfirm(econtext) {
preventSave(econtext);

Alert.show("This Function Is Go", null, [
new Alert.Button("Yes", function () {
_autoFired = true;
Xrm.Page.data.entity.save();
}, true, false),
new Alert.Button("No", function () {
Alert.show("It Is Not Save", null, [new Alert.Button("Close", null, true, false)], "INFO", 500, 200);
}, true, false)
], "QUESTION", 500, 200);
}
```

Regards,
Paul


Viewing all articles
Browse latest Browse all 170

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>