It's all about the answers!

Ask a question

How to get value of custom attribute of RTC WI .


Navneet Srivastava (17712) | asked Oct 03 '14, 7:11 a.m.
We have created two custom attribute in Defect workflow .
1) Current state: which get the calculated value by using WorkItemAttributes.STATE
2) Assingned to TechLead: This is of type contributor where user can choose one techlead from multiple set/

Now we want to write a calculated script which can set the "Owned by" value to the "assigned Tech lead" attribute value.

I am not able to get the value (Techlead name) of "Assigned to TechLead" attribute .

Please help .

+Navneet

Comments
Susan Hanson commented Oct 03 '14, 7:41 a.m.

What does your javascript look like now?  When you get the value of the attribute, what value do you get back?

Accepted answer


permanent link
Susan Hanson (1.6k2201194) | answered Oct 03 '14, 10:12 a.m.
So I was able to get this to work in a test project area.    Note that my STATE is different than yours, so you'll need to change that.  I tried to use the same attribute for Technical Lead as you did. 

Since you are making it a calculated value, RTC *assumes* that nobody else will change it other than the script, so that is why I get the owner and return the owner if it is not a defect or defect but not the right state.  If not, the if owner is set by someone else, it gets ignored.  I also did var's for everything so I could print things for debugging

dojo.provide("org.example.CalculatedOwner");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");

(function() {
dojo.declare("org.example.CalculatedOwner", null, {
   
    getValue: function(attributeId, workItem, configuration) {
        var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
        var wiType = workItem.getValue(WorkItemAttributes.TYPE);
        var wiState = workItem.getValue(WorkItemAttributes.STATE);
        var wiTechLead = workItem.getValue("com.wiley.workitem.attribute.assignedBA");
        var wiOwner = workItem.getValue(WorkItemAttributes.OWNER);

    if (wiType === "defect" && wiState === "com.ibm.team.workitem.defectWorkflow.state.s1" ) {
             return wiTechLead;
    } //type = defect
    else
        return wiOwner;
    }
});
})();
Navneet Srivastava selected this answer as the correct answer

2 other answers



permanent link
Navneet Srivastava (17712) | answered Oct 03 '14, 8:34 a.m.
dojo.provide("org.example.CalculatedOwner");

dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");

(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;

var CalculatedOwner= dojo.declare("org.example.CalculatedOwner", null, {

    getValue: function(attributeId, workItem, configuration) {
        console.log("Test");
if (workItem.getValue(WorkItemAttributes.TYPE) === "defect" && workItem.getValue(WorkItemAttributes.STATE) === "com.wiley.workitem.defectWorkflow.state.s1")

        return workItem.getValue(com.wiley.workitem.attribute.assignedBA);
    }
});
})();


permanent link
Navneet Srivastava (17712) | answered Oct 06 '14, 10:05 a.m.
Thanks a lot susan .. Appreciate your help .

BTW is it also possible to update the Subscriber list with the assignees Like as soon as owned by is Tech lead he should also get added to Subscriber list automatically .

Thanks
+Navneet

Comments
Ralph Schoon commented Oct 06 '14, 11:45 a.m. | edited Oct 06 '14, 11:47 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

As mentioned in your other question, the only way to access the subscriber list is using Java API. JavaScript does not allow to access and manipulate the data as far as I can tell. This has been discussed on this forum already.

You could potentially try to access the user list in the attribute, but you can not add them to the subscriber list as far as I can tell.

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.