Script within Workflow
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2015 08:37 AM
Good morning,
I would like to run a script within a custom workflow. This script must be run as soon as the User Approve the task.
The idea I had so far was to create a custom property (flag) to a document and update its value to true when the dcumento is approved. And then create a folder rule that calls the script when this property(flag) is updated.
But I prefer this script to be executed within the workflow directly.
Does anyone have any idea / suggestion to help me?
The script is attached
I would like to run a script within a custom workflow. This script must be run as soon as the User Approve the task.
The idea I had so far was to create a custom property (flag) to a document and update its value to true when the dcumento is approved. And then create a folder rule that calls the script when this property(flag) is updated.
But I prefer this script to be executed within the workflow directly.
Does anyone have any idea / suggestion to help me?
The script is attached
Labels:
- Labels:
-
Archive
script.txt.zip
2 KB
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2015 03:19 AM
Hi Frederico,
A workflow user Task has 3 events that can be invoked to achieve certain things.
1. Assignment = this fires when the sequence flow preceding it "ends". This is the first event to happen and even if the task ultimately is not created this event will fire.
2. Create = Upon successful creation of the "UserTask" this event is triggered.
3. Complete = This triggers on a successful completion of a task, if there was an error the task will not complete and the event won't be triggered.
That being said here is a way you can achieve your goal on your "Approval" user task:
It is important to note that whatever code you run inside the user Task, the assigned user has right to perform such instructions, unless you explicitly mention that the code be executed as admin. In this case you will need to add the following code on the tasklistener event:
Hope this answers your question.
A workflow user Task has 3 events that can be invoked to achieve certain things.
1. Assignment = this fires when the sequence flow preceding it "ends". This is the first event to happen and even if the task ultimately is not created this event will fire.
2. Create = Upon successful creation of the "UserTask" this event is triggered.
3. Complete = This triggers on a successful completion of a task, if there was an error the task will not complete and the event won't be triggered.
That being said here is a way you can achieve your goal on your "Approval" user task:
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener"> <activiti:field name="script"> <activiti:string><![CDATA[<import resource="classpath:alfresco/extension/workflows/scripts/updateMetadata.js">]]></activiti:string> </activiti:field> </activiti:taskListener>
It is important to note that whatever code you run inside the user Task, the assigned user has right to perform such instructions, unless you explicitly mention that the code be executed as admin. In this case you will need to add the following code on the tasklistener event:
<activiti:field name="runAs"> <activiti:string><![CDATA[admin]]></activiti:string></activiti:field>
Hope this answers your question.
