cancel
Showing results for 
Search instead for 
Did you mean: 

Custom action to add advance workflow to item

khinendra
Champ on-the-rise
Champ on-the-rise
Hi,

For adding simple workflow to item is already there in alfresco but for advance workflow there is no such action.

I want to create a custom action, when a new content with any specific type is added to any space I want to initiate an advance workflow on it.

How can I do it, please tell me the steps.

Thanks
Khinendra Bisen
8 REPLIES 8

jayjayecl
Confirmed Champ
Confirmed Champ
you want to create a custom content rule.
For that, you will not have to create a custom action, but just a script that can trigger an advanced-workflow.
And, with these new clues, you will surely find in this forum the script that will allow you to create your content rule.

hope this helps

khinendra
Champ on-the-rise
Champ on-the-rise
Hi,
I am not clear that how to create and trigger an action to initiate my custom advanced workflow.
Please tell me the steps.


Thanks
Khinendra

iblanco
Confirmed Champ
Confirmed Champ
Hi JayJayECL:

I used to run a workflow from a script as is explained in the already refered posts but now (in Alfresco 3.2) it does not run it says:

 ERROR [org.alfresco.web.ui.common.Utils] Failed to run Actions due to error: 09080028 Failed to execute script 'workspace://SpacesStore/0adac610
-09e4-40b2-9aec-ba165d0d57ac':
       09080027 Failed to signal transition 'null' from workflow task 'jbpm$21'
                      org.alfresco.scripts.ScriptException:
       09080028 Failed to execute script 'workspace://SpacesStore/0adac610-09e4-40b2-9aec-ba165d0d57ac':
       09080027 Failed to signal transition 'null' from workflow task 'jbpm$21'

It seems that in this new Alfresco release there is a WorkflowManager that is exposed to the scripts as "workflow" ( http://wiki.alfresco.com/wiki/Workflow_JavaScript_API ) but i do not know how to prepare a package and start a new workflow with this. Might the old way been deprecated ?

I can't find any example for the new way either.

Any suggestion ?

iblanco
Confirmed Champ
Confirmed Champ
In Alfresco 3.2 Community this seems to work for my advanced workflow:


var propiedades = new Object();
propiedades["bpm:workflowDescription"] = "Solicitud de pago de factura " + document.name;
propiedades["bpm:assignee"] = person;
propiedades["bnvwf:departmentChief"] = people.getPerson('usuario1');
propiedades["bnvwf:mainChief"] = people.getPerson('usuario2');
propiedades["bnvwf:archiveFolder"] = companyhome.childByNamePath("Facturacion/No aceptadas");
propiedades["bnvwf:removeFolder"] = companyhome.childByNamePath("Facturacion/Pendientes de pago");
var workflowFactura = workflow.getDefinitionByName('jbpm$bnvwf:departamentalInvoicePayment');
var paquete = workflow.createPackage();
paquete.addNode(document);
workflowFactura.startWorkflow(paquete, propiedades);

I think this might be a useful example.

iblanco
Confirmed Champ
Confirmed Champ
In fact the code works and the workflow is assigned but not automatically started. It seems that the starting task should be automatically ended, so the code would be like this:


var propiedades = new Object();
propiedades["bpm:workflowDescription"] = "Solicitud de pago de factura " + document.name;
propiedades["bpm:assignee"] = person;
propiedades["bnvwf:departmentChief"] = people.getPerson('elacunza');
propiedades["bnvwf:mainChief"] = people.getPerson('jbastarrika');
propiedades["bnvwf:archiveFolder"] = companyhome.childByNamePath("Facturacion/No aceptadas");
propiedades["bnvwf:removeFolder"] = companyhome.childByNamePath("Facturacion/Pendientes de pago");
var workflowFactura = workflow.getDefinitionByName('jbpm$bnvwf:departamentalInvoicePayment');
var paquete = workflow.createPackage();
paquete.addNode(document);
var workflowNodoInicial = workflowFactura.startWorkflow(paquete, propiedades);
/**
* Auto finalizar las tareas de inicio del workflow.
**/
var tareas = workflowNodoInicial.getTasks();
for (tarea in tareas) {
   tareas[tarea].endTask(null);
}

Sadly in my case when I use this script the execution fails with the annoying and already typical error that says that transition 'null' can not be signaled.

By the way I made this code after looking at this:

http://www.google.com/codesearch/p?hl=en&sa=N&cd=1&ct=rc#EKXcgWsKRRI/HEAD/root/projects/remote-api/c...

Can someone tell me if they have used this code or a similar one succesfully? When launched from the start advanced workflow wizard everything works right.

jpbarba
Champ in-the-making
Champ in-the-making
This approach is not enough, I mean using a script. In fact, the parameters must be inserted in code, ex.
user. Nowadays, this is the only solution, but these option might be included in future versions.

Greetings

iblanco
Confirmed Champ
Confirmed Champ
Great to hear that jpbarba.

By the way, the supplied code works in Alfresco Labs 3 Final, it seems that there is a bug in community 3.2 :

https://issues.alfresco.com/jira/browse/ALFCOM-3480