As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener"> <activiti:field name="script"> <activiti:string><![CDATA[ ……………………. var message = 'IT LIVES'; throw message;]]></activiti:string> </activiti:field> </activiti:taskListener>
… throw new Error("some text"); …
alert('welcome');
throw(message)
throw new Error("")
<serviceTask id="alfrescoScripttask1" name="Validate input params" activiti:class="org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate"> <extensionElements> <activiti:field name="script"> <activiti:string> <![CDATA[if (bpm_package.children.length == 0 ) { throw new Error ("No workflow folder found.Please select one."); } if (bpm_package.children.length > 1 ) { throw new Error ("More than one workflow attachments found, Please select only one workflow folder."); } ]]></activiti:string> </activiti:field> </extensionElements> </serviceTask>
<?xml version="1.0" encoding="UTF-8"?> <definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test"> <process id="myDemoProcess" name="My Demo Process" isExecutable="true"> <startEvent id="startevent1" name="Start"></startEvent> <userTask id="usertask1" name="User Task" activiti:assignee="admin"> <extensionElements> <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener"> <activiti:field name="script"> <activiti:string><![CDATA[throw new Error ("called");]]></activiti:string> </activiti:field> </activiti:taskListener> </extensionElements> </userTask> <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow> <endEvent id="endevent1" name="End"></endEvent> <sequenceFlow id="flow2" sourceRef="usertask1" targetRef="endevent1"></sequenceFlow> </process> <bpmndi:BPMNDiagram id="BPMNDiagram_myDemoProcess"> <bpmndi:BPMNPlane bpmnElement="myDemoProcess" id="BPMNPlane_myDemoProcess"> <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1"> <omgdc:Bounds height="35.0" width="35.0" x="210.0" y="200.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1"> <omgdc:Bounds height="55.0" width="105.0" x="290.0" y="190.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1"> <omgdc:Bounds height="35.0" width="35.0" x="440.0" y="200.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1"> <omgdi:waypoint x="245.0" y="217.0"></omgdi:waypoint> <omgdi:waypoint x="290.0" y="217.0"></omgdi:waypoint> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2"> <omgdi:waypoint x="395.0" y="217.0"></omgdi:waypoint> <omgdi:waypoint x="440.0" y="217.0"></omgdi:waypoint> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </definitions>
<activiti:string><![CDATA[throw new Error ("called");]]></activiti:string>
<activiti:string><![CDATA[throw new Error ("The values you entered are not correct");]]></activiti:string>
When alfresco is rendering the workflow form , it is rendering the transition button using the activiti-transition.js file.Basically this buttons are doing nothing more but submitting the workflow form.
This is how the flow is going when we submit a workflow form.
So the best to customize the error pop up is to change activiti-transition.ftl and activiti-transition.js file , to make an ajax call and handle the response as we want.
activiti-transition.js file has a function named as onClick: function ActivitiTransitions_onClick(e, p_obj).What it does is , it converts the form element in json object and finally submit that form.Below is line which is responsible for this.
Alfresco.util.submitForm(p_obj.getForm());
Inside this activiti-transition.js file if we do all this things manually and handle the server response, we will be able to handle the error message ultimately.