简体   繁体   中英

alfresco workflow isn't seeing webscript variables

I'm using alfresco as the backend workflow for a seperate front end web application(don't ask me why, ask the client). The front end server makes ajax calls to the backend alfresco webscripts. The problem I'm having is that the parameters set in my workflow webscript don't show up inside the custom workflow process's javascript.

Here's the essence of the webscript. The signal at the end is to get past the start node:

    var timestamp = new Date().getTime();
    contentName = args['name']+timestamp;
    var node = userhome.createNode(contentName, "wds:Promotion");
    node.properties["cm:name"]=args['title'];
    node.save();

    var workflowDefinition = workflow.getDefinitionByName("jbpm$pas:workflow");
    var workflowPackage = workflow.createPackage();
    workflowPackage.addNode(node);
    var workflowParameters = new Object();
    workflowParameters["bpm:groupAssignee"] = people.getGroup("regional");
    workflowParameters["pas:currentReviewGroup"] = "GROUP_Regional"
    var workflowPath = workflowDefinition.startWorkflow(workflowPackage, workflowParameters);

    workflowPath = workflowPath.signal(null);

This is the workflow. The problem is in the second stanza. Both pas_currentReviewGroup and bpm_groupAssignee are coming up null when they are set in the webscript. I use pas_customReviewGroup to keep track of where in the workflow I am, as the same few steps are repeated for different users, so there's just one set of tasks.

<start-state name="pas:start-state">
    <task name="pas:start" swimlane="initiator"></task>
    <transition name="" to="pas:SetCurrentGroup"></transition>
</start-state>

<node name="pas:SetCurrentGroup">
    <event type="node-enter">
       <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
                <variable name="pas_currentReviewGroup" access="read,write" />
                <variable name="bpm_groupAssignee" access="read"/>
                <expression>
                if (!pas_currentReviewGroup)
            {
                pas_currentReviewGroup = bpm_groupAssignee.properties.authorityName == "GROUP_Market" ? "GROUP_Regional" : "GROUP_Burbank";
               }
                </expression>
            </script>
        </action>
        </event>
    <transition name="" to="pas:DraftingUpload" />
</node>

<task-node name="pas:DraftingUpload">
    <task name="pas:draftingUpload" swimlane="CreatorGroup"/>
    <transition name="Submit" to="pas:PendingReview"></transition>
</task-node>

I read some stuff about ScriptableObject being needed for workflowDefinition.startWorkflow's workflowParameters, but I couldn't find anything about using it.

How do I set the aspect variables inside of the webscript so they show up in the workflow. When I view the item in alfresco share, the group assignee is populated.

Thanks in advance

What I use is a different way to start a workflow. I'm using the actionExecutor start-workflow.

var workflow = actions.create("start-workflow");
    workflow.parameters.workflowName = "jbpm$vxi:verwerkxmlin";
    workflow.parameters.startTaskTransition = "volgende";
    workflow.parameters["bpm:workflowDescription"] = "Automatische workflow";
    workflow.parameters["wn:xmlDocument"] = xml;
    workflow.execute(xml);

So in your case it should be the following:

var workflow = actions.create("start-workflow");

workflow.parameters.workflowName = "jbpm$pas:workflow";
workflow.parameters.startTaskTransition = "";
workflow.parameters["bpm:groupAssignee"] = people.getGroup("regional");
workflow.parameters["pas:currentReviewGroup"] = "GROUP_Regional";
workflow.execute(node);

And ps you're missing a semi-colon at line: workflowParameters["pas:currentReviewGroup"] = "GROUP_Regional"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM