Unable to execute script, returns null.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2014 08:54 PM
I've added a custom workflow in …/classes/alfresco/extension
pengesahan_processdefinition.xml
pengesahan-workflow-context.xml
and my javascript to call the workflow
Actually this is my second custom workflow. The first one works fine. The only difference is the wf:name and the xml filenames.
This new custom workflow would return unable to execute script because of null (after checking with logs, this I believe happens at line workflow.execute()).
Maybe I've missed something?
Thanks in advance.
pengesahan_processdefinition.xml
<?xml version="1.0" encoding="UTF-8"?><process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="wf:pengesahan"> <swimlane name="initiator" /> <start-state name="start"> <task name="wf:submitGroupReviewTask" swimlane="initiator" /> <transition name="" to="review" /> </start-state> <swimlane name="reviewer"> <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment"> <pooledactors>#{bpm_groupAssignee}</pooledactors> </assignment> </swimlane> <task-node name="review"><timer name="emailReminderTimer" duedate="8 minutes"> <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript"> <script>logger.log("send email");var mail = actions.create("mail");var node = people.getGroup(bpm_groupAssignee);if(node){var members = people.getMembers(node); }mail.parameters.subject=bpm_mailSubject;mail.parameters.text=bpm_mailText;mail.parameters.from = "alfrescousername@gmail.com"; for(var i=0;i < members.length;i++){mail.parameters.to = members.properties.email;mail.execute(bpm_package);} </script> </action> </timer> <task name="wf:reviewTask" swimlane="reviewer"> <event type="task-create"> <script> if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate; if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority; </script> </event> <event type="task-end"> <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript"> <script> <variable name="bpm_assignee" access="write"/> <expression> if (taskInstance.actorId != null) people.getPerson(taskInstance.actorId); else person; </expression> </script> </action> </event> </task> <transition name="Approve" to="approved"/> <transition name="Reject" to="rejected"/> </task-node> <task-node name="rejected"> <transition name="" to="end" ><action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript"><runas>admin</runas><script>logger.log("reject");var dest = companyhome.childByNamePath(bpm_rejectDestination);for (var i = 0 ; i < bpm_package.children.length; i++){bpm_package.children.move(dest);}</script></action></transition> </task-node> <task-node name="approved"> <transition name="" to="end"><action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript"><runas>admin</runas><script>if(bpm_package.children[0].mimetype!="application/pdf"){var contentPdf = bpm_package.children[0].transformDocument("application/pdf",dest);}else{logger.log("pdf");var contentCopy = bpm_package.children[0].copy(dest);}</script></action></transition> </task-node> <end-state name="end" /></process-definition>
pengesahan-workflow-context.xml
<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'><beans> <bean id="parallel.workflowBootstrap" parent="workflowDeployer"> <property name="workflowDefinitions"> <list> <props> <prop key="engineId">jbpm</prop> <prop key="location"> alfresco/extension/pengesahan_processdefinition.xml </prop> <prop key="mimetype">text/xml</prop> <prop key="redeploy">true</prop> </props> </list> </property> </bean></beans>
and my javascript to call the workflow
var workflow = actions.create("start-workflow");workflow.parameters.workflowName = "jbpm$wf:pengesahan";workflow.parameters["bpm:workflowDescription"] = "Proses pengesahan dokumen : "+document.properties.name;workflow.parameters["bpm:groupAssignee"] = "GROUP_KETUA URUSETIA SEKRETARIAT";workflow.parameters["bpm:approveDestination"] = "Sites/ar-rahnutest/documentLibrary/PAPARAN";workflow.parameters["bpm:rejectDestination"] = "Sites/ar-rahnutest/documentLibrary/TIDAK DILULUSKAN";var futureDate = new Date(); futureDate.setDate(futureDate.getDate() + 3); workflow.parameters["bpm:workflowDueDate"] = futureDate;workflow.parameters["bpm:workflowPriority"]="2";workflow.parameters["bpm:mailSubject"]="Peringatan : Sila lakukan pengesahan";workflow.execute(document);
Actually this is my second custom workflow. The first one works fine. The only difference is the wf:name and the xml filenames.
This new custom workflow would return unable to execute script because of null (after checking with logs, this I believe happens at line workflow.execute()).
Maybe I've missed something?
Thanks in advance.
Labels:
- Labels:
-
Archive
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2014 10:52 PM
Have you ever checked whether your process definition is successfully deployed using workflow console?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2014 08:51 PM
Hi, Thank you for the reply.
I've just checked and found out that instead of running the workflow, it runs the previous workflow that I used, wf:reviewpooled.
But I set the name as wf
engesahan, to run that workflow, what mistake have I done here?
I've just checked and found out that instead of running the workflow, it runs the previous workflow that I used, wf:reviewpooled.
But I set the name as wf

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2014 11:47 PM
1.Excecute "show definitions" command in workflow console ,make sure your definition is successfully deployed and make sure you specify the correct definition name in your javascrpt code.
2.I guess maybe you made somewhere,you can write your javascript code like below and it will give you more log info.
2.I guess maybe you made somewhere,you can write your javascript code like below and it will give you more log info.
var wfdef = workflow.getDefinitionByName("jbpm$wf:pengesahan");logger.getSystem().out(wfdef.getName());var wfparams = new Object();wfparams["bpm:workflowDescription"] = "Proses pengesahan dokumen : "+document.properties.name;wfparams["bpm:groupAssignee"] = "GROUP_KETUA URUSETIA SEKRETARIAT";wfparams["bpm:approveDestination"] = "Sites/ar-rahnutest/documentLibrary/PAPARAN";wfparams["bpm:rejectDestination"] = "Sites/ar-rahnutest/documentLibrary/TIDAK DILULUSKAN";var futureDate = new Date();futureDate.setDate(futureDate.getDate() + 3);wfparams["bpm:workflowDueDate"] = futureDate;wfparams["bpm:workflowPriority"]="2";wfparams["bpm:mailSubject"]="Peringatan : Sila lakukan pengesahan";var wfpackage = workflow.createPackage();wfpackage.addNode(document);wfdef.startWorkflow(wfpackage,wfparams);
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2014 02:53 AM
Hi,
Thank you! I'll try this out later.
I have to test out other things so I have to stick to using and editing from the workflow folder..
Thank you! I'll try this out later.
I have to test out other things so I have to stick to using and editing from the workflow folder..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2014 01:47 AM
Hi,
When you re-deploy your worklow in alfresco, it creates new version of the workflow.
So, please use the workflow console and find out how many versions of workflow you have.
Thanks.
Murali
When you re-deploy your worklow in alfresco, it creates new version of the workflow.
So, please use the workflow console and find out how many versions of workflow you have.
Thanks.
Murali
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2014 02:47 AM
Hi,
Does this means that it is better to leave the redeploy parameter as false?
So everytime I make changes to the workflow, does it still take effect?
Thank you.
Does this means that it is better to leave the redeploy parameter as false?
So everytime I make changes to the workflow, does it still take effect?
Thank you.
