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

Defaulting a Contributor attribute to "Created By"

In a work item, I would like to add another Contributor attribute, which can be modified, but I would like to default value to start out being the "Created By" person. I know that "Created By" is generated by the system, is there a way to get that field on the initial creation only to get copied into this new field?

Susan

0 votes



4 answers

Permanent link
I went back to the original first article, and looked again at the "Default Values" section, and there is a way to specify the "Authenticated User", which would be (on a create) the CreatedBy user. Once it is set, then the default value isn't needed, so that isn't a major problem and this SEEMS to do what I want (although I think I need to get "Unassigned" out of the list).

Steps:
go into Attribute Customization, add a default value, Category User and Configuration to Authenticated User. Then create the attribute and specify this default value as the Default Value.

Susan


Hi Susan,

the only solution for this I guess is mentioned in this article: http://jazz.net/library/article/537/. You could use a script based default value provider to achieve what you want. Please note that this is still experimental in 3.0. The article references more details in the Wiko here: https://jazz.net/wiki/bin/view/Main/AttributeValueProviders.

The code would look somewhat like this:

dojo.provide("com.example.common.valueprovider.default.contributor.CreatorContributor");

(function() {
dojo.declare("com.example.common.valueprovider.default.contributor.CreatorContributor", null, {

getDefaultValue: function(attribute, workItem, configuration) {
var value= workItem.get(com.ibm.team.workitem.api.common.WorkItemAttributes.CREATOR);
return value;
}

});
})();



Ralph


In a work item, I would like to add another Contributor attribute, which can be modified, but I would like to default value to start out being the "Created By" person. I know that "Created By" is generated by the system, is there a way to get that field on the initial creation only to get copied into this new field?

Susan

1 vote


Permanent link
Hi Susan,

the only solution for this I guess is mentioned in this article: http://jazz.net/library/article/537/. You could use a script based default value provider to achieve what you want. Please note that this is still experimental in 3.0. The article references more details in the Wiko here: https://jazz.net/wiki/bin/view/Main/AttributeValueProviders.

The code would look somewhat like this:

dojo.provide("com.example.common.valueprovider.default.contributor.CreatorContributor");

(function() {
dojo.declare("com.example.common.valueprovider.default.contributor.CreatorContributor", null, {

getDefaultValue: function(attribute, workItem, configuration) {
var value= workItem.get(com.ibm.team.workitem.api.common.WorkItemAttributes.CREATOR);
return value;
}

});
})();



Ralph


In a work item, I would like to add another Contributor attribute, which can be modified, but I would like to default value to start out being the "Created By" person. I know that "Created By" is generated by the system, is there a way to get that field on the initial creation only to get copied into this new field?

Susan

0 votes


Permanent link
Hi Susan,

great catch! It did not occur to me that the authenticated user would be the one you wanted. Thanks for figuring that out!

Ralph

I went back to the original first article, and looked again at the "Default Values" section, and there is a way to specify the "Authenticated User", which would be (on a create) the CreatedBy user. Once it is set, then the default value isn't needed, so that isn't a major problem and this SEEMS to do what I want (although I think I need to get "Unassigned" out of the list).

Steps:
go into Attribute Customization, add a default value, Category User and Configuration to Authenticated User. Then create the attribute and specify this default value as the Default Value.

Susan

0 votes


Permanent link
How do I use the script? Is the script attached to the project area to test?

Hi Susan,

great catch! It did not occur to me that the authenticated user would be the one you wanted. Thanks for figuring that out!

Ralph

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

Question asked: Jan 31 '11, 5:29 p.m.

Question was seen: 7,900 times

Last updated: Jan 31 '11, 5:29 p.m.

Confirmation Cancel Confirm