I am trying to catch FinishActivity in UI / UX when a user selects a parameter from a page or component.
Using the standard method of adding an extended command to the corresponding configuration file, I can add an interface and catch the isAvailable method using the scripts shown below.
Tridion.Extensions.CheckTitleOnFinishActivitySE = function Commands$CheckTitleOnFinishActivitySE() { Tridion.OO.enableInterface(this, "Tridion.Cme.Commands.CheckTitleOnFinishActivitySE"); this.addInterface("Tridion.Web.UI.Editors.SiteEdit.Commands.FACommand", ["CheckTitleOnFinishActivitySE", $const.AllowedActions.FinishActivity]); };
Tridion.Extensions.CheckTitleOnFinishActivitySE.prototype._isAvailable = function (selection) { var response = Tridion.Web.UI.Editors.SiteEdit.Commands.FinishActivity.prototype._isAvailable(selection); };
However, when I try to reuse the exisitng isEnabled function:
Tridion.Extensions.CheckTitleOnFinishActivitySE.prototype.isEnabled = function (selection) { var response = Tridion.Web.UI.Editors.SiteEdit.Commands.FinishActivity.prototype._isEnabled(selection); };
or even copying existing code from the siteedit function itself (which I obviously did not do)
Tridion.Extensions.CheckTitleOnFinishActivitySE.prototype.isEnabled = function (selection) { return (selection && selection.getProperty && selection.getProperty("isSEPage")) && this.callBase("Tridion.Cme.Command", "_isEnabled", [selection]); };
I get the following error:
Cannot execute the "FinishActivity" command on [tcm: 8-349-131200]. Reason: not included.
I can make this state turn on, using only return true from the isEnabled function, but I would prefer to inherit / reuse the existing check in order to support current and future scenarios ...
I can confirm that _isAvailable is caught and returns true and that the required function for the extension isEnabled, not _isEnabled (adding the latter alone or in addition to isEnabled has no effect)
Any advice would be great!
Thanks in advance.
Update - Add Debugging
So, I added the following to my extended isEnabled to track the difference between the response to the selection object in my isEnabled 'v' isEnabled by default:
In "workflow.js" a value is displayed if the isSEPage property is true, but when it is checked directly in my function, it is false. It reads sequentially that when called from my isEnabled in the original, it also returns false. I donβt understand what can happen to the choice or what will I deal with another object / context of choice?
Updated extended isEnabled with debugging scripts:
Tridion.Extensions.CheckTitleOnFinishActivitySE.prototype.isEnabled = function (selection) { $log.message('myfile.js::FinishActivity.prototype._isEnabled::selection.getProperty("isSEPage") = ' + selection.getProperty("isSEPage")); $log.message('myfile.js::FinishActivity.prototype.isEnabled ==> checking calling original...'); var response = Tridion.Web.UI.Editors.SiteEdit.Commands.FinishActivity.prototype._isEnabled(selection); $log.message('myfile.js::FinishActivity.prototype.isEnabled ==> ' + response); $log.message('myfile.js::FinishActivity.prototype.isEnabled ==> checking using copied code from original...'); return (selection && selection.getProperty && selection.getProperty("isSEPage")) && this.callBase("Tridion.Cme.Command", "_isEnabled", [selection]); };
Output (workflow.js represents the initial value of the workflow for the same evaluation)
workflow.js: FinishActivity.prototype._isEnabled :: selection.getProperty ("isSEPage") = true myfile.js :: FinishActivity.prototype._isEnabled :: selection.getProperty ("isSEPage") = undefined myfile.js :: FinishActivity. prototype.isEnabled ==> checking the call of the original ... workflow.js: FinishActivity.prototype._isEnabled :: selection.getProperty ("isSEPage") = undefined myfile.js :: FinishActivity.prototype.isEnabled ==> undefined myfile.js :: FinishActivity.prototype.isEnabled ==> verification using the copied code from the original ... Cannot execute the "CheckTitleOnFinishActivitySE" command on [tcm: 8-349-131200]. Reason: not included.
More debug
I see that in the original CME script workflow, isEnabled function does not exist at all?
I added the following to the isEnabled extended script:
Tridion.Extensions.CheckTitleOnFinishActivitySE.prototype.isEnabled = function (selection) { $log.message('myfile.js::FinishActivity.prototype._isEnabled::selection.getProperty("isSEPage") = ' + selection.getProperty("isSEPage")); $log.message('Tridion.Web.UI.Editors.SiteEdit.Commands.FinishActivity.prototype._isEnabled(selection) = ' + Tridion.Web.UI.Editors.SiteEdit.Commands.FinishActivity.prototype._isEnabled(selection)); $log.message('this.callBase("Tridion.Cme.Command", "_isEnabled", [selection]) = ' + this.callBase("Tridion.Cme.Command", "_isEnabled", [selection]));
as a result of:
myfile.js :: FinishActivity.prototype._isEnabled :: selection.getProperty ("isSEPage") = undefined Editor_v6.1.0.55920.269_.aspx: 7175 workflow.js: FinishActivity.prototype._isEnabled :: selection.getProperty ("isSEPage" ) = undefined Editor_v6.1.0.55920.269_.aspx: 7175 Tridion.Web.UI.Editors.SiteEdit.Commands.FinishActivity.prototype._isEnabled (choice) = undefined Editor_v6.1.0.55920.269_.aspx: 7175 this.callBase (" Tridion.Cme.Command "," _isEnabled ", [selection]) = false
Although the original (SiteEdit) is still running before my script and returns
workflow.js :: FinishActivity.prototype._isEnabled :: selection.getProperty ("isSEPage") = true
I am wondering if the Tridion SiteEdit isEnabled is checked when the FinishActivity option is selected, and my extension is executed when the FinishActivity is instantiated. I look further, but if someone sees something in iterin, it will be great!
thanks