cancel
Showing results for 
Search instead for 
Did you mean: 

Set WorkFlow "Required Approve Percent" in java

jamilnour
Star Contributor
Star Contributor

Hello,

Can anybody tell me how to set the "Required Approve Percent" variable in java when programmatically create a Workflow?

I can't find it in WorkflowModel. I only found the PROP_PERCENT_COMPLETE which is the percent complete and not the required percent.

In  link below the writer tells that, parameters.put(WorkflowModel.PROP_PERCENT_COMPLETE, 50) reflects the "Required Approve Percent = 50" which is not the case 

Alfresco · Starting workflow from Java | Programming and So 

In Javascript it is "wf:requiredApprovePercent" but what about java?

Thank you

Jamil

5 REPLIES 5

douglascrp
World-Class Innovator
World-Class Innovator

Yes, there is no QName defined for that one.

What you can do is create it by yourself in your code, with something like:

static final QName PROP_REQUIRED_APPROVE_PERCENT = QName.createQName(NamespaceService.BPM_MODEL_1_0_URI, "requiredApprovePercent");

and then, in your code, use it, like this:

parameters.put(PROP_REQUIRED_APPROVE_PERCENT, 50);

jamilnour
Star Contributor
Star Contributor

Unfortunately it is not working and I am having always 50

This is my code for requiredApprovedPercent:

static final QName PROP_REQUIRED_APPROVE_PERCENT = QName.createQName(NamespaceService.BPM_MODEL_1_0_URI, "requiredApprovePercent"
);
String requiredApprovePercent = (String) ruleAction.getParameterValue(PARAM_REQUIRED_APPROVE_PERCENT);
System.out.println("requiredApprovePercent:" + requiredApprovePercent);
System.out.println("requiredApprovePercent Int:" + Integer.parseInt(requiredApprovePercent));
System.out.println("PROP_REQUIRED_APPROVE_PERCENT" + PROP_REQUIRED_APPROVE_PERCENT);
workflowParameters.put(PROP_REQUIRED_APPROVE_PERCENT, Integer.parseInt(requiredApprovePercent));
...
Log:
requiredApprovePercent:100
requiredApprovePercent Int:100
PROP_REQUIRED_APPROVE_PERCENT{http://www.alfresco.org/model/bpm/1.0}requiredApprovePercent

Thank you

Jamil

douglascrp
World-Class Innovator
World-Class Innovator

How are you checking that information?

Where do you see the 50 value?

Have you tried starting the workflow using javascript and setting the property?

When you start the workflow by using the Share form are you able to set the property's value the way you need it?

The requiredApprovePercent is under the workflow model and not the BPM so the following should work:

static final QName PROP_REQUIRED_APPROVE_PERCENT = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "requiredApprovePercent");

workflowParameters.put(PROP_REQUIRED_APPROVE_PERCENT, 100);

Jamil

douglascrp
World-Class Innovator
World-Class Innovator

Good catch.