How do I calculate the summary field based on the custom attribute value in RTC using java script ?
Amit Saxena (31●1●15●16)
| asked Jul 03 '12, 8:05 a.m.
edited Jul 03 '12, 8:25 p.m. by Geoffrey Clemm (30.1k●3●30●35)
I have two custom attributes : A and B
Any Idea how to calculate the summary field based on the custom attribute value in RTC using script based calculated values |
6 answers
hope this helps!
https://jazz.net/wiki/bin/view/Main/AttributeCustomization#ScriptBasedNotes |
Hi Fausto,
Thanks for providing me the link. I have been using the same link to create the script: I have two attributes : Component name ( id: component_name) Component version ( id: component_version) and I want to combine both in to summary Here is my Script: -------------------- dojo.provide("com.example.Calculate_Component_Summary"); (function() { dojo.declare("com.example.Calculate_Component_Summary", null, { getValue: function(attribute, workItem, configuration) { var component = workItem.getValue(component_name); var version = workItem.getValue(component_version); var result+= component + " v" + version; return result; } }); })(); am i doing something wrong here ? Comments
Fausto Lemos
commented Jul 03 '12, 9:23 a.m.
Did you set this ValueSet for Summary field and added "component_name" and "component_version" as dependencies? |
Dinesh Kumar B (4.1k●4●13)
| answered Jul 03 '12, 9:04 a.m.
JAZZ DEVELOPER edited Jul 03 '12, 9:06 a.m.
when I use the custom attributes i use the below two points
1. use the ID of the attribute and not the name 2. use the ID from within double quotes for an attribute named Criticality with an ID rcstlt.ms.criticality var rCrit = workItem.getValue("rcstlt.ms.criticality"); gets me the valuethe rest of your script looks fine to me. |
Hi,
I am not using the name i am using the ID i have put "" around the id now also I have already set this ValueSet for Summary field and added "component_name" and "component_version" as dependencies it is still not working. I am using the in built summary attribute is that a problem. |
At https://jazz.net/wiki/bin/view/Main/AttributeCustomization#ScriptBasedNotes
Only values of the following attribute types can be safely read by and returned from scripts:
The summary field type is "Medium HTML" so will not work... |
Dinesh Kumar B (4.1k●4●13)
| answered Jul 04 '12, 4:12 a.m.
JAZZ DEVELOPER edited Jul 04 '12, 4:27 a.m.
Your code works for me when i modify the line:
var result+= component + " v" + version; tovar result = component + " v" + version; and use double quoted attribute ids, for reference here is the code which worked for me:the code dojo.provide("com.example.Calculate_Component_Summary"); the attribute types(function() { dojo.declare("com.example.Calculate_Component_Summary", null, { getValue: function(attribute, workItem, configuration) { var component = workItem.getValue("component_name"); var version = workItem.getValue("component_version"); var result = component + " v" + version; return result; } }); })(); and the component summary is the built-in summary type component name and version are of small string type the dependencies the summary attribute has dependency set on both component version and component name |
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.