Set user name automatically in “Owned by” field while changing the status of workitem in RTC
Dears,
We are planning to set user name automatically in “Owned by” field while changing the status of specific workitem(Change Request) in RTC. So I have created the below “calculated values” script to set RTC user name automatically in “Owned by” field but it is not working for me. Could you please correct me on this script? and let us know the right script for my requirement. Thanks in advance!
FYI,
dojo.provide("DefaultOwner"); dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); // To access the work item attributes dojo.require("com.ibm.team.workitem.api.common.Status"); // To create a status object to return dojo.require("com.ibm.team.workitem.api.common.Severity"); // To create a severity for the status
(function() {
dojo.declare("DefaultOwner", null, {
getValue: function(attributeId, workItem, configuration) { var state = workItem.getValue(com.ibm.team.workitem.api.common.WorkItemAttributes.STATE); // var ManagerName = workItem.setValue(Rajiv Gandhi); // var SetName = "Rajiv Gandhi";
var ManagerName = workItem.setOwner("Rajiv Gandhi"); if((workItem.getValue(com.ibm.team.workitem.api.common.WorkItemAttributes.TYPE)=="change_request") && (state == "ChangeRequestWorkFlow.state.s45")){ return ManagerName; } } }); })();
Thanks, Rajivgandhi |
Accepted answer
the Owner field contains an object reference, not a string.
somehow you have to lookup the object from the users name string. I haven't done this.. the javascript functions are limited in what they can do. see this https://jazz.net/wiki/bin/view/Main/AttributeCustomizationExamples#Get_an_item_s_UUID_users_iterati Rajiv Gandhi selected this answer as the correct answer
Comments Also note, that your calculation has to ALWAYS return a value. It is a function, a function has to always return a value to be syntactically correct. So you have to return the current value, if you don't want to change it.
I think it would be better to create a follow up action. That would have a lot more API access as well and could e.g. find the manager by role, which a JavaScript calculated value can't.
Rajiv Gandhi
commented Jan 18 '16, 3:47 p.m.
Hi Ralph, Thanks for the valuable information. |
4 other answers
I have followed the below steps from wiki page as mentioned Sam and Ralph. Now my requirement is working fine. Thanks Sam and Ralph for the valuable information. Automatically set the value of an attribute based on stateScenario: You need to automatically set the value of a work item attribute (e.g. Owner) when it is in a particular state (e.g. Verified)Solution: Use a calculated value customization
|
how to get Workflow state ID?
in your program u mentioned
workItem.getValue(WorkItemAttributes.STATE) === "4"
how to know ids of custom workflow state or default workflow state?
Comments
Ralph Schoon
commented Mar 04 '17, 10:29 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
See https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Accessing_an_item_s_Status_attri the state ID's can be found in the process configuration source and some historical information is mentioned in the documentation.
Debugging or console.log are obviously always an option as well. |
Hi, This solution is working for me. How can I set the owner for multiple workitem types through single script? for eg.
if (workItem.getValue(WorkItemAttributes.TYPE) === "defect") {
|
Can some one please tell the accurate place to put <ValueProvider> tag in process config?
I tried but getting the Unsupported value - _wgiM4O5SEem3D5FEFVFywQ in logs. Need some assistance.
Comments
Ralph Schoon
commented Feb 04 '20, 10:08 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
It puts itself in there, if you configure one. Use a test environment to play around with it. Then look into the process configuration.
Also see https://jazz.net/library/article/537 and https://jazz.net/wiki/bin/view/Main/AttributeCustomization
Also please ask your own questions and do not comment questions in other users questions answers.
|
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.