Set Workflow state/action via javascript
4 answers
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
Thanks Ralph. If Javascript solution is not possible, i will use the follow-up action.
Ralph ralph ralph....
I think you guys (or at least one of you) should put more effort in clearing things about Javascript and RTC.
I don't know if I'm wrong again... but this counterproofing is terrible tiring.
Please add at least one guy to this Forum who KNOWS this system!
But one question from me.
Is there other Javascript running on your systems despite in the WebUI Extensions?
Isn't attribute Customisation plain Java?
This is all internal API, not documented and not supported, subject to change, at own risk. It should not be used in any normal use case.
The normal use case is attribute customization, which I have spent weeks creating a workshop with my colleagues. And it still does not get read as far as I can tell from questions I frequently answer on the forum.
JavaScript as term is also misleading. It is available as language for attribute customization - with a very limited API.
If you want to customize the web pages, you would however use JavaScript as well, but I would not consider this a normal use case.
As long as I don't have a need, I won't dig into that. I am also not a developer of these products, I just have happened to learn much about its customization capabilities. I like Java better for many reasons.
I would rather have some customization UI and or a richer internal customization API to allow users to achieve what they want.
JavaScript run-time is also (for attribute customization) running in the Eclipse client.
I assume it is mostly used for the UI.
2 votes
Thanks for clarification!
You sir, are a great guy!
I always assumed you should be a developer, because of your forum title.
Great work you do here.
I don't know where the JazzDeveloper tag comes from but I am listed as Forum Admin and Moderator. 8)
I missed a point in your question. You can do Attribute customization with Java, as discussed in that Wiki page and in https://rsjazz.wordpress.com/2013/06/26/attribute-customization-java-based-value-providers-conditions-and-validators/ . But unlike me a lot of users don't like Java Extensions and want a scripting solution - which I can understand. I think this is what drove the JavaScript API.
We have several product developers, support colleagues and other experts following the forums and answering questions (you could relate my role with the last two categories).
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
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.