There is a DataObject method called setStatus that requires a Status object (an enum?) as a parameter. Unfortunately, there is also no documentation about the Status class and how to identify the value to be passed in the parameter.
Since the status field is an id to a Workflow Status object, how do you acquire the valid values setting (new) or updating (change) the status on a DataObject?
So, tor now (because getByName() is not available), what I have had to do is:
1) Make certain that all the Workflow Statuses are in the same Workflow Process
Note: This requires Triggers or Workflow Actions to be built to assign an action even it will never be used.
2) Iterate through the results of DataObject.getProcess().getAllStatuses() for the object for the Workflow Process associated with the current status (normally default) and perform a code compare (status.getCode()). When the correct status is found, save it.
3) Call DataObjectHandler.setStatus(runner.getTransaction(), data, newStatus, runner.getUser(), runner) to save the status.
This appears to be working without any issues.
You can use StatusHandler.getByName(DataObjectDef objDef, String systemCode)
objDef - the object definition that you are dealing with myDataObj.getObjectDef()
systemCode - integration name for the workflow status field in your object
Care to identify which library this is in? It does not appear in any of the normal jar files.
Apologies. The class is apparently obfuscated and not exposed as a public interface.
Could you try using DataObject.getProcess().getAllStatuses() ? All classes are from rb_core.jar.
That will return List<Status> assigned to workflow process. But please check first whether Process is null or not :)
I do not recommend using DataObject.setStatus() API since it will not make changes persistent. Use DataObjectHandler.setStatus() instead. Pass ID of status you wish to set. Example:
DataObjectDef objDef = DataObjectDefHandler.getByName(runner.getCustomer(), "invoice");
DataObject data = DataObjectHandler.getDataObject(runner.getCustomer(), objDef, id);
Status newStatus = StatusHandler.getByName(objDef, "posted");
DataObjectHandler.setStatus(runner.getTransaction(), data, newStatus, runner.getUser(), runner);
Thanks - I caught that - and was forced into doing a supplemental update to persist the change. Much better to use the single step.
Are you using any other Rollbase Java APIs or planning to use? I'm working on providing code samples and guidelines in JavaDoc.
StatusHandler is not available in the APIs. As Santosh posted above: the class is apparently obfuscated and not exposed as a public interface.
I confirm that StatusManager class and other classes from Workflow package are obfuscated. I'll check with management whether we want to open these classes for 3rd-party developers.
Yes, that should work.
Sorry for the trouble. Like Pavel said, we will check and see if there is a possibility to make this easier. Thanks for your patience. :)