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

Access custom attribute in a Calculated attribute script

I would like to automatically assign a user to the Owned By field from a "user" custom attribute upon the work item being a certain state. I implement it as a scripted calculated attribute associated with the Owned By field. I can't figure out why my script does not work. It does not update the Owned By field, and it does not give me any error message in the log or on screen. I tried outputing a test string to the log file and it worked. So I have confirmed that I have the correct set up to run the script upon work item state changes. Would someone be able to tell me what I have done wrong??

My custom attributes are:
				        <customAttribute id="buo" name="Business Unit Owner" type="contributor"/>

			        <customAttribute id="tpa" name="Technical Process Analyst" type="contributor"/>



Below is the script that I have associated as a Calculated Value with the Owned By field.
dojo.provide("org.example.workitems.providers.CalculatedOwner");



dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");

(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;


dojo.declare("org.example.workitems.providers.CalculatedOwner", null, {


getValue: function(attributeId, workItem, configuration) {

if (workItem.getValue(WorkItemAttributes.STATE) == "com.ibm.team.rtc.workflow.adoption.state.s1") return workItem.getValue("buo");
else return workItem.getValue("tpa");
}
});
})();


Thanks,
Alan

0 votes



2 answers

Permanent link
Hi alan, this post is quite old, however the calculated values are pretty restricted in handling Item Types such as owner. Please have a closer look here: https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Debugging_scripts
For items like users the scripting does not yet work.

0 votes

Comments

Hi, I have the same situation with alan, but I have tested that the opposite way is possible, I can assigned the build-in attribute  to a custom attribute with both of contributor type, why is this, cannot we get the build-in attribute's value?


Permanent link
To access other custom attributes in your script, you need to add the other attributes in the "dependencies" list when you create your custom variable in the process confguration (in the "Types and attributes" section).

I have made the following script, where "cost_internal" and "cost_external" are the custom variables:


dojo.provide("com.example.ValueProvider");

(function() {
    dojo.declare("com.example.ValueProvider", null, {

        getValue: function(attribute, workItem, configuration) {

		return workItem.getValue("cost_external") + workItem.getValue("cost_internal");
        }
    });
})();
Important: Also, remember to enable the "Enable process attachment scripts" option in "advanced settings" on your CCM server (using the web ui or teamserver.properties).

Also, even though I'm returning a long (external + internal) my "total_cost" variable is of type "smallString" becuase of a bug in RTC 3.0.1 that will not display numeric custom variables from scripts apparantly.

Hope this helps someone out there :-).

0 votes

Comments

Also remember to update your script under Project -> links when you update your script code. After you do this, a reboot of the server, or a manual change to the process xml might be required, to make the change visible to the server.

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
× 10,930

Question asked: Aug 31 '11, 5:27 a.m.

Question was seen: 8,951 times

Last updated: Apr 02 '13, 4:03 a.m.

Confirmation Cancel Confirm