Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customize or change default message boxes issued by workflow dialogs on errors in Alfresco

Presently, a messagebox appears with the failing class name:

enter image description here

Is it possible to override the default behavior in Alfresco? Could we use forms service to present a different message ?

like image 669
Luis Sánchez Avatar asked Jan 14 '23 10:01

Luis Sánchez


1 Answers

Additional to zladuric answer,

you can use failureCallback method to show message what you want. But it is difficult to search failureCallback method of workflow forms for a new one because workflow forms such as "Start Workflow", "Task Edit", "Task Detail" are used form engine.

For example, in "Start Workflow" form, you can add our own successCallBack and failureCallBack by writing onBeforeFormRuntimeInit event handler in start-workflow.js like this.

 onBeforeFormRuntimeInit: function StartWorkflow_onBeforeFormRuntimeInit(layer, args)
          {
            var startWorkflowForm = Dom.get(this.generateId + "-form");
            Event.addListener(startWorkflowForm, "submit", this._submitInvoked, this);

            args[1].runtime.setAJAXSubmit(true,
             {
                successCallback:
                {
                   fn: this.onFormSubmitSuccess,
                   scope: this
                },
                failureCallback:
                {
                   fn: this.onFormSubmitFailure,
                   scope: this
                }
             });
          }

 onFormSubmitSuccess: function StartWorkflow_onFormSubmitSuccess(response)
      {
        this.navigateForward(true);
    // Show your success message or do something.
      }
onFormSubmitFailure: function StartWorkflow_onFormSubmitFailure(response)
      {
        var msgTitle = this.msg(this.options.failureMessageKey);
        var msgBody = this.msg(this.options.failureMessageKey);

        // example of showing processing response message
        // you can write your own logic
        if (response.json && response.json.message) 
        {
            if(response.json.message.indexOf("ConcurrencyFailureException") != -1) 
            {
                msgTitle = this.msg("message.concurrencyFailure");
                msgBody = this.msg("message.startedAgain");
            }
            else
                msgBody = response.json.message;
        }
        Alfresco.util.PopupManager.displayPrompt(
                {
                    title: msgTitle,
                    text: msgBody
                });
      }

Since Alfresco.component.StartWorkflow(in start-workflow.js) extends Alfresco.component.ShareFormManager(in alfresco.js). You can override onBeforeFormRuntimeInit event in start-workflow.js. I hope this your help you.

like image 83
swemon Avatar answered Mar 18 '23 23:03

swemon