Set Workflow state/action via javascript
4 answers
https://jazz.net/wiki/bin/view/Main/AttributeCustomization does not provide any API to set the action that takes you to another state. The API is really made to return attribute values e.g. after a calculation. The attribute
You can do this kind of extension in a follow up action (Java extension). An example can be found here: https://rsjazz.wordpress.com/2012/11/27/resolve-parent-if-all-children-are-resolved-participant/
WorkItemAttributes.STATE
is available. I have however only read it so far. You can try to return a state in a calculated attribute, however, as that is not really triggering a workflow action and might not work. I think it won't.
You can do this kind of extension in a follow up action (Java extension). An example can be found here: https://rsjazz.wordpress.com/2012/11/27/resolve-parent-if-all-children-are-resolved-participant/
Comments
2 votes
Ok,
Hopefully I can help you.
First of all some Information.
1: If you wanna make state changes. You have to follow the exact process which you have implemented. E.g. You can't set a Workitem direct to Done, if your workflow didn't want this. So you have to make each step, you normally do.
But you could automate this process .
2: Read the WorkItem storage thread I've made.
https://jazz.net/forum/questions/166636/how-to-add-links-to-a-workitem-in-rtc-5x-jsdojo
Because you'll do it this way. But instead of changing a link, you'll change the state of your WI.
Remember, you'll need to save it as many times as you'll need a state change.
new -> doing -> done : this means two save procedures.
3: Where is the State information hided.
You'll need a working copy from your WI.
Under Point 2 you'll learn how to do that.
aValues = this.workingCopyProxy.getEditPropsValuesForAttribute('actionValues');
actionLabel = 'Start Working'; //Stands for state NEW
//Get the StateId throught the label.
var action_id = '';
for (i in aValues) {
if (aValues[i].label == actionLabel) {
action_id = aValues[i].id;
break;
}
}
//Then bouild a proper parameter to save the WI
var params = {};
params.attributeId = 'workflowAction';
params.isInitialization = false;
params.path = ["attributes", "workflowAction", "id"];
params.value = action_id;
//Set the value of your WI
this.workingCopyProxy.setValue(params);
//And then Store it on the DB
this.workingCopyProxy.storeWorkItem({ //Explained under 2
Hopefully I can help you.
First of all some Information.
1: If you wanna make state changes. You have to follow the exact process which you have implemented. E.g. You can't set a Workitem direct to Done, if your workflow didn't want this. So you have to make each step, you normally do.
But you could automate this process .
2: Read the WorkItem storage thread I've made.
https://jazz.net/forum/questions/166636/how-to-add-links-to-a-workitem-in-rtc-5x-jsdojo
Because you'll do it this way. But instead of changing a link, you'll change the state of your WI.
Remember, you'll need to save it as many times as you'll need a state change.
new -> doing -> done : this means two save procedures.
3: Where is the State information hided.
You'll need a working copy from your WI.
Under Point 2 you'll learn how to do that.
aValues = this.workingCopyProxy.getEditPropsValuesForAttribute('actionValues');
actionLabel = 'Start Working'; //Stands for state NEW
//Get the StateId throught the label.
var action_id = '';
for (i in aValues) {
if (aValues[i].label == actionLabel) {
action_id = aValues[i].id;
break;
}
}
//Then bouild a proper parameter to save the WI
var params = {};
params.attributeId = 'workflowAction';
params.isInitialization = false;
params.path = ["attributes", "workflowAction", "id"];
params.value = action_id;
//Set the value of your WI
this.workingCopyProxy.setValue(params);
//And then Store it on the DB
this.workingCopyProxy.storeWorkItem({ //Explained under 2
Yes IT IS Possible!
But to set this clear, I'm talking about the WebUI! With Dojo and JS
If you mean this, comment here, and I'll give you an answer.
I've got a "Set Done" Button in one of my Widgets.
But to set this clear, I'm talking about the WebUI! With Dojo and JS
If you mean this, comment here, and I'll give you an answer.
I've got a "Set Done" Button in one of my Widgets.