Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Set Contributer Type using script

 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);
}

        }
    });
})();

0 votes


Accepted answer

Permanent link
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

0 votes

Comments

 Thanks Ralph

This worked


One other answer

Permanent link
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

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 12,030

Question asked: Oct 07 '16, 10:36 a.m.

Question was seen: 2,456 times

Last updated: Oct 10 '16, 10:13 a.m.

Confirmation Cancel Confirm