Custom Ribbon controls EnabledScript no longer works due to a change in sp.ribbon.js.
In one environment, it is using an older version of the script and it works. In another environment, there is a more recent script version and the button EnabledScript does not run.
I found a difference between old and new in sp.ribbon.js (starting at line 246):
OLD:
if (!SP.Ribbon.SU.$0($v_1) && $v_1.toLowerCase().startsWith("javascript:")) {
window.g_CUIcommandId = $p1;
var $v_5 = eval($p0.EnabledScript);
window.g_CUIcommandId = null;
return $v_5
}
NEW:
if (!$v_4 && !SP.Ribbon.SU.$0($v_1) && $v_1.toLowerCase().startsWith("javascript:")) {
window.g_CUIcommandId = $p1;
var $v_8 = eval($p0.EnabledScript);
window.g_CUIcommandId = null;
return $v_8
}
The $v_4 is true, causing my script to not run. Here
is additional information (from sp.debug.js) that was added to the new script:
var $v_2 = $p0.CommandAction;
var $v_3 = !SP.Ribbon.SU.$0($v_2) && $v_2.startsWith('javascript:LaunchApp('); var $v_4 = $v_3 && !SP.PageContextInfo.get_isAppWeb();