It's all about the answers!

Ask a question

Set Contributer Type using script


Pankaj Sharma (401169) | asked Oct 07 '16, 10:36 a.m.
 Hello Team,

I am using RTC 6.0.2
I want to set Contributer Attribute with a particular user name on save of WI.

I want to do it using dojo Script, Please help me.
My code is below:

dojo.provide("com.example.IssueFLValueProvider");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
    dojo.declare("com.example.IssueFLValueProvider", null, {
        getValue: function(attribute, workItem, configuration) {

var subSystem = '';
var FL = [];
subSystem = workItem.getLabel("com.ibm.team.workitem.attribute.SuspectedAreaList");

if(subSystem == "XXX")
{
 
FL.push("Pankaj Sharma"); 

}
try
{
return FL;
}
catch
{
console.log(err.message);
}

        }
    });
})();

Accepted answer


permanent link
Ralph Schoon (63.1k33646) | answered Oct 10 '16, 2:23 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Oct 10 '16, 4:17 a.m.
https://jazz.net/wiki/bin/view/Main/AttributeCustomization mentions

Only values of the following attribute types can be safely read by and returned from scripts: .......
  • Limited support for Items

Currently there is no dedicated API to work with Items or Enumerations and scripts can only use the id of such attributes. If you need additional information, such as the name that corresponds to an Enumeration literal id, you can pass it to scripts using configuration parameters. See the Configuring additional script parameters section for more information.


A contributor is an item type and you need to set the ID of the item. The ID looks like "_SLSW8JQLEd-DaZzUk6UM4g" and can be obtained in the URI of the users user profile or using getValue() on an contributor attribute.
Pankaj Sharma selected this answer as the correct answer

Comments
Pankaj Sharma commented Oct 10 '16, 10:13 a.m.

 Thanks Ralph

This worked

One other answer



permanent link
Donald Nong (14.5k414) | answered Oct 10 '16, 1:26 a.m.
If you want to set a value to an attribute when saving a work item, you should use a Calculated Value provider. You script shown above is a Value Set provider, which provides a set of values for a certain attribute. I suggest you read through the below article and wiki to have better understanding the attribute customization topic.
https://jazz.net/library/article/1003
https://jazz.net/wiki/bin/view/Main/AttributeCustomization

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.