Attribute Customization - Calculated Value - Comment Timestamp
Hi
I need to have a custom attribute saving the timestamp when a comment is added. I have a script that saves the timestamp, but it updates every time the Work Item is saved.
dojo.provide("com.saveCommentDate"); dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function(){ var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes; var fromISOString = dojo.date.stamp.fromISOString; dojo.declare("com.saveCommentDate", null, { getValue: function(attribute, workItem, configuration) { var now = new Date(); return dojo.date.stamp.toISOString(now, {milliseconds:true, zulu:true}); }} ); })(); Anyone who knows how can I check if the update comes from a new comment? Or, how to execute the script only on comment updates?
Thanks!
Accepted answer
This is not going to work. Read https://jazz.net/wiki/bin/view/Main/AttributeCustomization to understand when and how often the scripts are called - it is more often than you think. Also play close attention to what attribute types are supported and which are not (the ones NOT mentioned as supported).
Also consider
-
https://jazz.net/library/article/1003
- Lab 5
- https://rsjazz.wordpress.com/2016/07/15/rtc-process-customization-what-you-can-and-cannot-do/
I don't think what you try is acievable with attribute customization. A work item save follow up action could do this however.
Comments
Thanks for the answer. I was thinking about identifying if a new comment was added or not, and save the timestamp if there is a new comment...
As far as I can tell, there IS NO way for you to detect comments in java script attribute customization. Even if, there is likely no timestamp. the API does not support complex attribute types. What is supported is listed in the link.
I have explained the same stuff over and over again. Please read the links I provided. Good luck.