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

How to get a calculated values script to work

New to RTC and I'm trying to get a calculated values script to work. I've tried using the sample in this article: https://jazz.net/library/article/1003/

Nothing happens when I create a work item or edit and then save the work item. I was expecting the script to run and to update the custom attribute that uses the Calculated Value script. The attribute does have dependencies selected.

Questions:

1. If the script throws errors where can I find the error log?

2. Any tips on where to look for why it's not working?

Version of RTC is 4.0.3

Thanks!

0 votes



2 answers

Permanent link
Hello,

the most often overlooked factor is that you need to enable the scripts. Search for the Enable Process Attachment Scripts and make sure it is set to true. Search for it in Advanced Properties. This is described in the document you mentioned, so just to double check.

Once you save the workitem, you can check ccm.log to see if the script generated any error.

0 votes

Comments

There is a brief discussion here on debugging via the web UI (and much more discussion about attribute customization in general -- note the section about the JavaScript API as not all attribute types are easily handled in scripting). Once you set the debug flag you can use the developer tools in the browser to set breakpoints in the script and investigate what's happening. You can also use console.log() if you'd prefer and look for that output in the browser console.

Thanks for the replies!

The Current Value was set to True.

Where can I find the ccm.log?

Thanks!

Assuming you're using Tomcat, it is located in
<JazzServer>/server/logs

In case of WAS:
<WebSphere install dir>/AppServer/profiles/<profile name>/logs


Thanks again. Found the WebSphere directory (has lots of files) but don't see a ccm.log file.

Depending on how your CCM application is named, the log file can be named differently. 'ccm' is the default name, but can also be jazz.log, or something else.

Did you search for ccm.log and not find one anywhere in that folder?


Personally, I've always use the debug URL and the browser debugger to work on scripts. It's typically quite simple:
  1. Add ?debug=true to the right part of the URL (before the #)
  2. Open browser developer tools
  3. Reload page if needed
  4. Open Source Panel and look for your named script
  5. Set a breakpoint on one of the early lines of your script 
  6. Step through it using the inspector to see what is happening
  7. (often notice stupid JavaScript syntax error that was the problem all along)
If someone hasn't made a short video/tutorial for this already, perhaps I will. If I can find one I'll add here.

Thanks again. I'm checking ever file (that has been recently modified) in the logs folder. Haven't found it yet but I'm still looking.

Millard 

 Yes.

Trying to debug. Using Firefox. Its lists tons of javascript files except for the one I want it to list.

Did you enable process scripting (if needed) as Piotr mentioned? Yes, it's a long list, but your file should be there using the name you gave it. In Chrome, my scripts are often at the end of the long list of files. If you type the first few characters of your script name, won't FF filter the list for you? Anyway, if process customization scripts are enabled, your file should be there somewhere. 

Using IE and I'm able to debug now. Finding some errors. Thank you both for your help. Just need to fix some errors.

Did you enable process scripting (if needed) as Piotr mentioned? Yes it was already enabled.

Seems like the script (for the calculated value) is never being reached because it is first failing on an error of "Object doesn't support property or method 'getElementByTagName". I removed the calculated value script and ran while debugging and I'm getting the same error.

hmm, I'm using 4.0.3 and I don't recall seeing any errors. Are you using an example from the article exactly or using the article as guidance? Unless that error is tanking your whole UI, it's probably just moving on. Maybe time to switch back to FF. ;-) 

I was using the Age Calculation script. I removed it and then started debug while editing a work item and I get the "Object doesn't support property or method..." error when trying to Save. The Save won't complete until I stop debugging. When not in debug mode I can edit and save the work item with no problems.

I guess I'll try FF again.

I think your right it is just moving on. Thus no errors are being hit within the CalculateAge script (added it back in) but the field is not being updated.

Is the script being run? Is it returning the correct value? Put a breakpoint on several lines and make sure the code is executing and know what it is returning. If you copied the code exactly, you may want to change it to create the return value, then return it, so you can see the value in the debugger.


Ah, just read through the example more carefully. Because it is dependent on ModificationDate and that won't change on the client, it may not update until saved and that update may not happen until the server side and won't be visible in the client unless it is refreshed. An unfortunate example as you can't debug it on the client or even see it change on the client as you'd expect. I guess the way it is intended to work, you make changes, save, then the Age updates.

You can always cheat -- make it dependent on something else you can change in the UI so you can see it work. If you make it dependent on, say, Description, you should be able to trigger it from the UI.

I'll give that a try. thanks for the suggestion.

A "Unknow type" error is being thrown.

Still can't find the CalculateAge script to be able to put break points in it. Any hints on finding the script while debugging (Using FireFox or IE)?

Try using Chrome, I find it easier to find the scripts. We described debugging with FireFox a bit in Lab 5 of https://jazz.net/library/article/1093 (At the end), but I sometimes find the scripts immediately and sometimes find myself frantically trying to find them in FireFox.

FYI, some scripts might run on the server and not in the client.

In Chrome Use Tools>Developertools and you can find the scripts in Resources>Frames>(window)>Scrips, I believe.

Ralph - thanks for the suggestion but unfortunately I won't be abble to use google chrome.

I've been working an article that lays out the process with a detailed example, including debugging steps, etc. Using a relatively recent version of Firefox (ESR 24.0) I don't see the script. Filtering the list doesn't find it and a massive scroll and stare doesn't either. Works fine in Chrome. Let me try IE. Mostly wanted you to know I haven't given up on this.

Wow, nor in IE. This works perfectly in Chrome (sorry you are unable to use it). I'll see if I can figure out what's up, but I can't offer you much help with debugging this in a non-Chrome environment if we can't figure out how to find the script. 


I was able to use console.log("got to here"); and see those in the FF console, but that's not a very productive way to work (and you can't use the debugger to inspect the structure of things that way).

Thank you very much for looking into this!!

I'm happy to share a draft of the piece I'm working on in case it will help. Shoot me an email: millarde@us.ibm.com 

Just sent you an email. Thanks again!

showing 5 of 27 show 22 more comments

Permanent link
I'm hoping this new article will help you figure this out: https://jazz.net/library/article/1360

0 votes

Comments

Thanks again Millard! I haven't had a chance to work on this task for awhile now. I appreciate all the help you have provided.

My pleasure. If you have more questions, just ask them. 

Will do. Thanks!

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: Oct 29 '13, 11:39 a.m.

Question was seen: 6,082 times

Last updated: Dec 10 '13, 12:39 p.m.

Confirmation Cancel Confirm