Questions about Scripting in process definitions

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2009 05:22 AM
Hi all,
I have some troubles with improving myself at scripting inside process definitions :
1/ I'm struggling due to the lack of documentation about scripting : http://forums.alfresco.com/en/viewtopic.php?f=19&t=17570
2/ I have a problem with this example :
http://wiki.alfresco.com/wiki/WorkflowAdministration#Step_3:_Add_Behaviour_to_the_Process_Definition
you can see two examples of syntax :
and
When do we need to add the "<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">" tag ?
Another example you could find : when do we need to use tag <expression> ???
What are the differences ?
3/ My concrete problem is the following.
I have a task model with a multivalued property :
When they browse the associated form, users (it's a "pooledactors-task") can add many little comments.
I'm trying to manipulate those comments in the following task :
Here are the questions :
- I found it strange that
Then, I happily found out that replacing "void" by "null" worked.
- the previous code :
As fca:commentaire2 is a multivalued property, I thought that previousComms would be a List object. It seems not to be.
- At last, what I'm trying to achieve is to manipulate this property : when a user browse the form of this task, he can see the previous comments that were made (read-only), and can enter a new one. I just want this field to be prepopulated with the name of the user (then, you basically have a textarea you can edit, but there is already "yourname : " in it)
I have some troubles with improving myself at scripting inside process definitions :
1/ I'm struggling due to the lack of documentation about scripting : http://forums.alfresco.com/en/viewtopic.php?f=19&t=17570
2/ I have a problem with this example :
http://wiki.alfresco.com/wiki/WorkflowAdministration#Step_3:_Add_Behaviour_to_the_Process_Definition
you can see two examples of syntax :
<task name="wf:adhocTask" swimlane="assignee"> <event type="task-create"> <script> if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate; if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority; </script> </event> </task>
and
<transition name="" to="completed"> <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript"> <script> if (wf_notifyMe) { var mail = actions.create("mail"); mail.parameters.to = initiator.properties["cm:email"]; mail.parameters.subject = "Adhoc Task " + bpm_workflowDescription; mail.parameters.from = bpm_assignee.properties["cm:email"]; mail.parameters.text = "It's done"; mail.execute(bpm_package); } </script> </action> </transition>
When do we need to add the "<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">" tag ?
Another example you could find : when do we need to use tag <expression> ???
What are the differences ?
3/ My concrete problem is the following.
I have a task model with a multivalued property :
<type name="fca:poc2TaskDiscussion"> <parent>bpm:workflowTask</parent> <properties> <property name="fca:commentaire2"> <type>d:text</type> <multiple>true</multiple> </property> </properties> <overrides> <property name="bpm:packageActionGroup"> <!– <type>d:text</type> –> <default>read_package_item_actions</default> </property> </overrides> </type>
When they browse the associated form, users (it's a "pooledactors-task") can add many little comments.
I'm trying to manipulate those comments in the following task :
<task name="fca:poc2TaskDiscussion" swimlane="assignees"> <event type="task-create"> <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript"> <runas>admin</runas> <script> logger.log("1"); var previousComms = taskInstance.getVariable("fca_commentaire2"); if(previousComms != null) logger.log("2 " + previousComms.length); </script> </action> </event> </task>
Here are the questions :
- I found it strange that
if(previousComms != void)
raised syntax errors.Then, I happily found out that replacing "void" by "null" worked.
- the previous code :
previousComms.length
does not work : the log is 10:02:11,112 User:admin DEBUG [repo.jscript.ScriptLogger] 110:02:11,112 User:admin DEBUG [repo.jscript.ScriptLogger] 2 undefined
As fca:commentaire2 is a multivalued property, I thought that previousComms would be a List object. It seems not to be.
- At last, what I'm trying to achieve is to manipulate this property : when a user browse the form of this task, he can see the previous comments that were made (read-only), and can enter a new one. I just want this field to be prepopulated with the name of the user (then, you basically have a textarea you can edit, but there is already "yourname : " in it)
Labels:
- Labels:
-
Archive
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2009 05:58 AM
I can answer one of your questions
When do we need to add the "<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">" tag ?
This tag tells the following script that it is "AlfrescoJavaScript", without the tag the script component will be "Bean Shell Script" which is probably not what you were expecting.
One of the important things is that AlfrescoJavaScript has the "Root scope objects" defined, Bean Shell does not.
When do we need to add the "<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">" tag ?
This tag tells the following script that it is "AlfrescoJavaScript", without the tag the script component will be "Bean Shell Script" which is probably not what you were expecting.
One of the important things is that AlfrescoJavaScript has the "Root scope objects" defined, Bean Shell does not.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2009 06:01 AM
Thank you mrogers, this is a perfect answer for that very question
