It's all about the answers!

Ask a question

Defaulting a Contributor attribute to "Created By"


Susan Hanson (1.6k2201194) | asked Jan 31 '11, 5:29 p.m.
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

4 answers



permanent link
Susan Hanson (1.6k2201194) | answered Feb 04 '11, 8:34 a.m.
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

permanent link
Ralph Schoon (63.3k33646) | answered Feb 04 '11, 2:54 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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

permanent link
Ralph Schoon (63.3k33646) | answered Feb 04 '11, 9:05 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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

permanent link
Raj K (10222225) | answered Mar 23 '11, 8:52 a.m.
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

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.