Set Workflow state/action via javascript
![]()
VK L (817●7●151●159)
| asked Nov 25 '14, 11:53 p.m.
edited Nov 26 '14, 2:43 a.m. by Ralph Schoon (62.3k●3●36●43)
Hi All,
Is it possible to set the RTC Workflow state/action transition using JavaScript?
Please advise.
Thanks
|
4 answers
![]()
Ralph Schoon (62.3k●3●36●43)
| 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 Thanks Ralph. If Javascript solution is not possible, i will use the follow-up action. Ralph ralph ralph....
2
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.
Thanks for clarification!
![]() 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)
|
![]()
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 |
![]()
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.
|