Access custom attribute in a Calculated attribute script
Alan Kan (61●1●13●10)
| asked Aug 31 '11, 5:27 a.m.
edited Apr 02 '13, 4:03 a.m. by Ralph Schoon (63.5k●3●36●46)
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"); Thanks, Alan |
2 answers
Ralph Schoon (63.5k●3●36●46)
| answered Dec 01 '11, 3:28 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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. Comments
haizi wu
commented Nov 18 '12, 1:39 a.m.
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? |
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 :-). Comments
Morten Madsen
commented Nov 23 '12, 5:02 a.m.
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
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.