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

How do I calculate the summary field based on the custom attribute value in RTC using java script ?

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

0 votes



6 answers

Permanent link
hope this helps!

https://jazz.net/wiki/bin/view/Main/AttributeCustomization#ScriptBasedNotes

0 votes


Permanent link
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 ?

0 votes

Comments

Did you set this ValueSet for Summary field and added "component_name" and "component_version" as dependencies?


Permanent link
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 value

the rest of your script looks fine to me.

0 votes


Permanent link
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.



0 votes


Permanent link
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:
    • Short String
    • Medium String
    • Large String
    • Integer
    • Long
    • Boolean
    • Timestamp as an ISO-8601 standard string. Use dojo.date.stamp to convert a Javascript Date object to and from an ISO-8601 string. When converting a Date object to a string set the milliseconds and the zulu options to true.
      • To convert the value of a timestamp attribute with the id attributeId to a Date object use:
        var date= dojo.date.stamp.fromISOString(workItem.getValue(attributeId));
      • To convert a Date object to an ISO-8601 string use:
        var string= dojo.date.stamp.toISOString(date, {milliseconds:true, zulu:true});
    • Limited support for Enumeration. See the Working with Enumerations section for more information about using Enumerations in scripts.
    • Limited support for Items

The summary field type is "Medium HTML" so will not work...

0 votes


Permanent link
Your code works for me when i modify the line:
var result+= component + "  v" + version;
to
var 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");

(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;
        }
    });
})();

the attribute types
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


0 votes

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

Question asked: Jul 03 '12, 8:05 a.m.

Question was seen: 5,008 times

Last updated: Jul 04 '12, 4:27 a.m.

Confirmation Cancel Confirm