cancel
Showing results for 
Search instead for 
Did you mean: 

AVM Workflow

rdifrango
Champ in-the-making
Champ in-the-making
I was looking for documentation on the workflow API's and I found the following post that was somewhat helpful:

http://forums.alfresco.com/en/viewtopic.php?f=27&t=14019&p=47827

The problem with the simple-avm-submit is that everything gets moved directly into staging without going through the approval process.  My guess is that the start-avm-workflow.  Is this correct if I want to have documents from contributors to land in the approvers task list?  If not what is the correct approach?  Also, does this action find every document that needs to be submitted?

Here is the start of my web script that work for the simple option:

script:
{
var storeid = "portal" +
((args.user != null) ? "–" + args.user : "");
var fullpath = "/www/avm_webapps/ROOT/";

if (fullpath.length == 0)
{
status.code = 400;
status.message = "Store id has not been provided.";
status.redirect = true;
break script;
}

// locate avm node from path
var store = avm.lookupStore(storeid);
if (store == undefined)
{
status.code = 404;
status.message = "Store " + storeid + " not found.";
status.redirect = true;
break script;
}
var node = avm.lookupNode(storeid + ":" + fullpath);

if (node != null)
{
var workflowType = "jbpm$wf:simple-avm-submit";

var description = args.desc;

var workflow = actions.create("simple-avm-submit");

workflow.parameters.workflowName = workflowType;

workflow.parameters["bpm:workflowDescription"] = description;

if ((args.duedate) && (args.duedate != ""))
{
var dueDate = new Date(args.duedate);
workflow.parameters["bpm:workflowDueDate"] = dueDate;
}

workflow.execute(node);
}

}
1 REPLY 1

rdifrango
Champ in-the-making
Champ in-the-making
OK, I got it working how I want sort of now.  It appears as though, if I hard code the assignee then it properly goes through the approval process.  The question is, how do I dynamically find out from the workflow the assignee and if it is parallel or serial, etc.

Here is my code:

script:
{
   var currentUser = null;
   var impersonateUser = args.impersonate;
   
   if (impersonateUser != null) {
      currentUser = impersonation.impersonate(impersonateUser);
   }
   
   var storeid = "portal" +
      ((impersonateUser != null) ? "–" + impersonateUser : "");
    var fullpath = "/www/avm_webapps/ROOT/";
   
    if (fullpath.length == 0)
    {
      status.code = 400;
      status.message = "Store id has not been provided.";
      status.redirect = true;
      break script;
    }
   
    // locate avm node from path
    var store = avm.lookupStore(storeid);
    if (store == undefined)
    {
      status.code = 404;
      status.message = "Store " + storeid + " not found.";
      status.redirect = true;
      break script;
    }
    var node = avm.lookupNode(storeid + ":" + fullpath);

if (node != null)
{
   var workflowType = "jbpm$wf:simple-avm-submit";

    var description = "Portal Checkin";

    var workflow = actions.create("simple-avm-submit");

    workflow.parameters.workflowName = workflowType;
   
    workflow.parameters["bpm:workflowDescription"] = description;

    var assignTo = people.getPerson("approver");
    workflow.parameters["bpm:assignee"] = assignTo;

    if ((args.duedate) && (args.duedate != ""))
    {
       var dueDate = new Date(args.duedate);
       workflow.parameters["bpm:workflowDueDate"] = dueDate;
    }

    workflow.execute(node);
}

}