The Xrm.Utility library in Dynamics CRM 2013 provides new functions to display alerts and confirmations in CRM forms. In previous versions of CRM, you would have to use the alert() and confirm() JavaScript functions, but these are now supported in the CRM 2013 SDK with some additional options.
Xrm.Utility.alertDialog
This function takes in two parameters:
message: The message you wish to display in the alert.
onCloseCallBack: A function to execute when the user clicks on OK or closes the alert window using the X button.
Example:
The following code will display an alert and then will set the field of a Contact to ” when the user clicks on OK.
CRM2013.
showAlert = function ()
{
Xrm.Utility.alertDialog("This will set the First Name to , function ()
{
Xrm.Page.getAttribute("schema name of filed").setValue("value");
}
);
}
Xrm.Utility.confirmDialog
This function takes in three parameters:
message: The message you wish to display in the alert.
yesCloseCallback: A function to execute when the user clicks on Yes.
noCloseCallback: A function to execute when the user clicks on Cancel.
Example:
The following code will prompt the user to confirm if they want to save the form. If they select Yes, the form will save. If they select Cancel, the Email Address field will have focus set.
CRM2013.
showConfirmation = function ()
{
Xrm.Utility.confirmDialog("Are you sure you want to save this record?",
function () {
Xrm.Page.data.entity.save();
},
function () {
Xrm.Page.getControl("schema name").setFocus();
});
}
Xrm.Utility.alertDialog
This function takes in two parameters:
message: The message you wish to display in the alert.
onCloseCallBack: A function to execute when the user clicks on OK or closes the alert window using the X button.
Example:
The following code will display an alert and then will set the field of a Contact to ” when the user clicks on OK.
CRM2013.
showAlert = function ()
{
Xrm.Utility.alertDialog("This will set the First Name to , function ()
{
Xrm.Page.getAttribute("schema name of filed").setValue("value");
}
);
}
Xrm.Utility.confirmDialog
This function takes in three parameters:
message: The message you wish to display in the alert.
yesCloseCallback: A function to execute when the user clicks on Yes.
noCloseCallback: A function to execute when the user clicks on Cancel.
Example:
The following code will prompt the user to confirm if they want to save the form. If they select Yes, the form will save. If they select Cancel, the Email Address field will have focus set.
CRM2013.
showConfirmation = function ()
{
Xrm.Utility.confirmDialog("Are you sure you want to save this record?",
function () {
Xrm.Page.data.entity.save();
},
function () {
Xrm.Page.getControl("schema name").setFocus();
});
}
Interesting post. I Have Been wondering about this issue, so thanks for posting. Pretty cool post.It 's really very nice and Useful post.Thanks python代写
ReplyDelete