Показать сообщение отдельно
Старый 16.07.2015, 07:14   #1  
Blog bot is offline
Blog bot
Участник
 
25,491 / 846 (79) +++++++
Регистрация: 28.10.2006
mscrmblog: CRM 2015 save method with callbacks to navigate away from an error
Источник: http://mscrmblog.net/2015/07/16/crm-...from-an-error/
==============

Recently i stumbled upon an edge case scenario where the logged in user that has access to the record was making a specific change to the record which in turn fired the elevated plugin which removed his access and threw this strange error:
Server Is Busy

The record was saved. However, the data could not be displayed because the server is busy…



During my investigation, i had to come up with a way to remove this annoying error and take them back to the grid screen. Thankfully the Xrm.Page.data has a method save with the option to set callback functions to be executed after the save operation is completed.

Hooking onto these methods, i threw an alert and used the history.go method to return to the grid.

Notice the set_forceNavigationAway method, this is used to disable the the onbeforeunload message that CRM prompts saying you have unsaved changes to the form.

Xrm.Page.data.save().then( function() { // success callback }, function(errorCode, message) { // failure callback due to no access alert("You no longer have access to this Incident."); //this seems to work only in chrome Mscrm.RefreshPageHandler.set_forceNavigationAway(true); //this seems to work both in IE and chrome Mscrm.ReadFormUtilities.set_forceNavigationAway(true); window.LOCID_FORMS_SAVE_CONFIRM_TITLE = ""; window.history.go(-1); });



Источник: http://mscrmblog.net/2015/07/16/crm-...from-an-error/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.