Retrieving mandaory attributes from a criteria in a PX
I have a workflow attached to an ECO. Within a specific status of the workflow, I would like to write a Java PX to retrieve all the mandatory attributes from all the criteria, to validate to see if there are any values missing. If a value is missing, I would like to present the user with an error and not allow the workflow approval process to take place.
Is this possible? If so, any example code would be greatly appreciated.
The problem I see is if you collect all the mandatory fields from all the criteria then why have more than one criteria? I am guessing if there is more than one criteria there is a reason for that.
Hi,
Please refer to this thread having similar query:
https://myagileplm.com/questions/eco-workflows-getting-stuck-because-of-required-fields/
The sample code to retrieve mandatory fields is here as follows:
IWorkflow wf = (IWorkflow) session.getAdminInstance().getNode(NodeConstants.NODE_AGILE_WORKFLOWS).getChildNode(“My Sample Workflow”);
INode child;
for(IStatus status : wf.getStates()){
System.out.println(“For status “+status.getName());
for(Object obj : status.getChildNodes()){
child = (INode)obj;
for(Object o : child.getChildNodes()){
System.out.println(“For workflow status criteria: “+((INode)o).getName()+”, the exit required field is: “+((INode)o).getProperty(new Integer(202)).getValue().toString());
}
}
}
Instead of going this way, you can simply call IChange.audit() method which returns a map and then iterate through it to get your required data.
Regards,
Swagoto