It's all about the answers!

Ask a question

Set Workflow state/action via javascript


VK L (8177157159) | asked Nov 25 '14, 11:53 p.m.
edited Nov 26 '14, 2:43 a.m. by Ralph Schoon (63.5k33646)
 Hi All,
Is it possible to set the RTC Workflow state/action transition using JavaScript?

Please advise.
Thanks

4 answers



permanent link
Ralph Schoon (63.5k33646) | answered Nov 26 '14, 2:43 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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 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
VK L commented Nov 26 '14, 5:25 a.m.

 Thanks Ralph. If Javascript solution is not possible, i will use the follow-up action.


Jonas Studer commented Nov 26 '14, 8:11 a.m. | edited Nov 26 '14, 8:13 a.m.

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?


2
Ralph Schoon commented Nov 26 '14, 8:38 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


Jonas Studer commented Nov 26 '14, 9:22 a.m. | edited Nov 26 '14, 9:22 a.m.

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.


Ralph Schoon commented Nov 26 '14, 9:34 a.m. | edited Nov 26 '14, 9:35 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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).


permanent link
Jonas Studer (207917) | answered Nov 26 '14, 8:08 a.m.
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

permanent link
Jonas Studer (207917) | answered Nov 26 '14, 3:40 a.m.
edited Nov 26 '14, 4:45 a.m.
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.

Comments
VK L commented Nov 26 '14, 5:24 a.m.

 Hi Jonas,

I dont need a UI-button. But Dojo,JS scripts is ok. Please provide details and i will use it to suit my requirement.
Thanks.


permanent link
VK L (8177157159) | answered Nov 26 '14, 5:25 a.m.
 Hi Jonas,
I dont need a UI-button. But Dojo,JS scripts is ok. Please provide details and i will use it to suit my requirement.
Thanks.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.