Set or change default messages issued by workflow dialogs on errors in Alfresco

Currently, a message appears with the name of the failed class:

enter image description here

Is it possible to override the default behavior in Alfresco? Can we use the forms service to submit another message?

+4
source share
3 answers

Additional answer to zladuric,

you can use the failCallback method to show the message what you want. But it’s hard to find the failCallback method for business process forms for the new, because it uses workflow forms such as “Start Workflow”, “Edit Task”, “Task Details”.

For example, in the Start Workflow form, you can add our own successCallBack and failureCallBack by writing an onBeforeFormRuntimeInit event handler in workflow.js .

  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 the onBeforeFormRuntimeInit event in start-workflow.js. Hope this helps you.

+5
source

I am not looking at the code right now, but it looks like a normal YUI dialog. So he fired YUI. So this YUI is the client side, perhaps on the My-tasks taskbar or my task page.

In addition, the error message looks like this: status.message from a failed backend message / service.

You can probably find this client-side javascript file, find the method that launches the task, and see what this “failCallback handler” is. Then edit this failCallback method and make it show something other than response.status.message or something else. Maybe something like this.msg ("message.my-custom-error-message"); which you then configure yourself.

+4
source

Changing script scenarios for YUI can affect other functions. If we configure start-workflow. js, it will only be achieved in the form of starting a workflow.

So, as a general solution, the following is a suggestion.

When alfresco displays a workflow form, it passes the transition button using the activiti-transition.js file. Typically, these buttons do nothing but submit a workflow form.

Thus, the best way is to configure this activiti-transition.ftl and activiti-transition.js file, make an ajax call and process the response as we want.

I just looked at the full flow of how this front end error is shown.

  • activiti-transition is a form of workflow.
  • Using a function called submitForm, which is inside alfresco.js, it raises a form submit event
  • Inside the forms-runtime.js file, there is one function called _submitInvoked (handles the form submit event), which is responsible for creating an ajax request and submitting the workflow form. If there is an error while sending, it will display an error coming from the backend.
0
source

All Articles