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
Susan
4 answers
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
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
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:
Ralph
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
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
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