throw new Error in Alfresco workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2016 08:10 AM
I tried to do this
<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>
I tried doing this also
…throw new Error("some text");…
Since I am writing here it means it didn't work.
Please can somebody help me?
Just a simple alert window doesn't help me if the user submits the action after all. I need something to stop the user from continuing the process if the data he entered is not correct.
Thanks in advance,
Irena
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2016 09:05 AM
So, if you call
alert('welcome');
will not show.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2016 05:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2016 08:45 AM
Use the method in this way and it should work:
throw(message)
that will throw a popup on your screen.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2016 03:32 AM
It looks like that throw expects to get something else. I tried adding message as you suggested but it doesn't work.
I am putting this code inside the workflow definition. Maybe I am supposed to put it somewhere else?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2016 05:16 AM
You have to use
throw new Error("")
to error message to the user.Here is the code snippet to throw error message to user.
<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>
Hope this helps you.
Thanks,
Murali.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2016 05:49 AM
I need to throw the error when the user makes a choice in the workflow - when he completes a task. This is so in order to not let the user task to continue if the info entered is wrong. So I tried throwing error in the complete event of the user task.
Is this possible?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2016 02:31 AM
I use it with a user task, though as a supplied script. I write a separate script and embed it to the user task, that way I do not have to redeploy the bpm every time I make changes.
Try using the "throw" in a independent script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2016 12:56 PM
If you use the service task, it is failed, I believe , the current task will not be completed and goes back to prev. task. I am not sure what happen if you update some values in the system.
<?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>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2016 01:11 AM
