It's all about the answers!

Ask a question

Attribute Customization - Calculated Value - Comment Timestamp


Pablo Vera (111) | asked Feb 02 '18, 2:51 p.m.
edited Feb 03 '18, 4:07 a.m. by Ralph Schoon (63.1k33645)
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


permanent link
Ralph Schoon (63.1k33645) | answered Feb 03 '18, 4:06 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Feb 03 '18, 4:36 a.m.

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

I don't think what you try is acievable with attribute customization. A work item save follow up action could do this however.

Ralph Schoon selected this answer as the correct answer

Comments
Pablo Vera commented Feb 14 '18, 9:25 a.m.

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


Ralph Schoon commented Feb 14 '18, 9:43 a.m. | edited Feb 14 '18, 9:43 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.

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.