It's all about the answers!

Ask a question

script based calculated values using custom attributes

Christine Makasy (731023) | asked Sep 09 '14, 2:55 a.m.
Just for testing purposed I tried to add a script based values to the defect editor and I don't know how to address these script based values.
Please find below the script:


(function() {
var WorkItemAttributes =;

    dojo.declare("com.example.calculateValue", null, {

        getValue: function(attribute, workItem, configuration) {
        //var n = parseInt(workItem.getValue('note1ID'));
        var n = workItem.getValue(""));
        var p = parseInt(workItem.getValue('pointsID'));
        //var n = 99;
        //var p = 3;
        var calcNotePoints;
        calcNotePoints = n * p;
        //calcNotePoints = 444;
        return parseInt(n);

Having just a simple assignment of a value like calcNotePoints = 444; the attribute in the work item editor shows the value.
Do you have an idea how to address these custom values in the Java Script?
Many thanks, Christine

Accepted answer

permanent link
Dinesh Kumar B (4.1k413) | answered Sep 09 '14, 3:19 a.m.
edited Sep 09 '14, 3:26 a.m.
Hi Christine,

There is additional closing parenthesis in the following code piece :
    var n = workItem.getValue(""));
please correct it and check if it helps.

In general to be able to access the custom attributes, you have to
a.  refer to their ID
b.  placed within single or double quotes
c.  from workItem.getValue. 
I do see that you are mostly covering all the three mentioned above, but that extra ) may be causing the failure.

one more to check is the return value, i see that you are returning n and not calcNotePoints, not sure if you intended to.
hope it helps.
Christine Makasy selected this answer as the correct answer

Christine Makasy commented Sep 09 '14, 4:30 a.m.

Many thanks. Now I removed the second ), tried it again, but with the same result. The value entered in the attribute note1 will not be shown in the attribute based on the script.
I just want to display an attribute entry entered in an editor field in another editor field.

Could you please have a look again, thanks, Christine            

Dinesh Kumar B commented Sep 09 '14, 5:16 a.m.

ok two more things to check are :
1.  setting of the calculated value script to the attribute which is expected to receive the return value from the script
2.  attribute dependency on the source attributes.

For the ID, It's the id of the attribute itself and not a combination of multiple fields. 

Assuming you are using the Eclipse Client, if you double click on the attribute from the attributes list for the work item type, the value that shows up in the ID field is what you should be using.

and please go through the Lab Ralph suggests.  Its extensive, clear and a nice asset on customizations in RTC.

Susan Hanson commented Sep 09 '14, 5:48 a.m.

Have you done some console.log() statements to validate that you are getting what you think?  For example, what is the value of n before the ParseInt that gets returned?

Christine Makasy commented Sep 23 '14, 8:57 a.m.

Many thanks for your help, the hint with the console.log() Statement leaded to the solution.

One other answer

permanent link
Ralph Schoon (62.9k33645) | answered Sep 09 '14, 3:19 a.m.
I don't understand the question. However, if you are looking for more information have a look at Lab 5

If you ask for the custom attributes and how to access them in a script, use


Christine Makasy commented Sep 09 '14, 4:38 a.m.

Sorry, but I don't understand the expression I addressed the my custom attribute with the category and the id mentioned in the process configuration source. Could you please explain?

Ralph Schoon commented Sep 09 '14, 5:07 a.m.

You basically click on the custom attribute, go to the identifier text box, copy the content and paste it into the quotation marks. E.g you replace the with the ID string for your attribute. The work item type category does not play any role in the ID for the attribute. I'd suggest to follow the links I provide above. It is worth it.

Christine Makasy commented Sep 23 '14, 8:56 a.m.

many thanks for your help, it is solved now

Your answer

Register or to post your answer.