It's all about the answers!

Ask a question

Javascript (Calculated Value) is not called when workitem is created neither is saved


Pietro Bottino (35614) | asked Sep 23 '15, 10:25 a.m.
edited Sep 23 '15, 10:48 a.m.
Hello.

I need a help... The article https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Configuring_a_script_based_custo (Calculated Value Section) says :

"If you configure a Script-based calculated value, the script will be executed in three cases:

    When a work item is created, the script is executed
    When a work item is saved, the script is executed to recalculate the value.
    When an attribute which the current attribute depends on is changed, the value of the current attribute is recalculated. Depending on the presentations of the two attributes this may not work in all cases."


I created a script, but only works when an attribute which the current attribute depends on, is changed!

I put my browser in debug mode(https://jazz.net/library/article/1360), but o script only stops in breakpoint for the third situation.

Does someone knows why?

Thanks!

Comments
Ralph Schoon commented Sep 23 '15, 10:44 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Pietro Bottino commented Sep 23 '15, 10:50 a.m.

I'm sorry Ralph. I created a Calculated Value.

PS: I edited the question.


Tiago Moura commented Sep 23 '15, 11:01 a.m. | edited Sep 23 '15, 11:02 a.m.

I suggest you to start simple, put only a log message in your code. Check the execution using a debug tool. Is it working? Step forward, implement a more complex code, test and repeat the process.


Keep in mind, change one thing at time, so you would be able to know if such change works or not. 

2 answers



permanent link
Donald Nong (14.5k414) | answered Sep 24 '15, 3:20 a.m.
If I'm not mistaken, the script is executed on the server side for the first two cases, so you cannot set breakpoints in it on the client side (the browser). To debug, use console.log() and check the output in the Eclipse .log file on the server. This file can be found as /opt/IBM/JazzTeamServer/server/tomcat/work/Catalina/localhost/ccm/eclipse/workspace/.metadata/.log on Linux with the bundled Tomcat.

permanent link
Ralph Schoon (63.1k33646) | answered Sep 23 '15, 11:16 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Sep 23 '15, 11:23 a.m.
Pietro,

I think the description is correct, I am not sure if your debugger can block on the call for creation and save. Mine (Chromium) couldn't. The trigger worked on the change of the dependent attribute only. But I was able to see that the script was run at all the occasions. I configured the description and another attribute (severity). I saw Test in the description, after the work item was created. I saw TestTest after saving, changing the severity added another test.

/*******************************************************************************
 * Licensed Materials - Property of IBM
 * (c) Copyright IBM Corporation 2011. All Rights Reserved.
 *
 * Note to U.S. Government Users Restricted Rights:  
 * Use, duplication or disclosure restricted by GSA ADP Schedule 
 * Contract with IBM Corp. 
 *******************************************************************************/
dojo.provide("com.example.ValueProvider");

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

        getValue: function(attribute, workItem, configuration) {
				
			return workItem.getValue(attribute) + "Test";
			
        }
    });
})();

Your answer


Register or 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.