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

Script for calling timestamp value only works with readonly enabled.

I am working with customer to implement their own script so that once date is set for custom attribute (type-timestamp, field A), same date value is copied and displayed on (type-timestamp, field B).

It seens as it can be only achieved when readonly=true is true for field B. When readonly=false for field B, value set for field A is not shown on field B. Customer advised they would like to know if it can be achieved without having to set field B to readonly.

Below are steps to reproduce

1. Create a sample project
2. Add custom attribute (Name : Field A, ID : cm_act_start_date, Type : timestamp)
3. Add the script to calculated Values (Provider : Script Based Calculate Value)
4. Edit Field B (pre-existing attribute, select script then add Field A in dependency)
5. a. Field B is readonly - When date is selected for Field A, same value will be shown on Field B
    b. Field B is not readonly - When date is selected for Field A, no value will be shown on Field B

Below is script used for calculated value

dojo.provide("com.abc.ams.ValueProvider.SetValueDueDate");

(function() {
dojo.declare("com.abc.ams.ValueProvider.SetValueDueDate", null, {
getValue: function(attribute, workItem, configuration) {
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.date");
dojo.require("dojo.date.stamp");
   
var workitem_attributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
var cm_act_start_date= dojo.date.stamp.fromISOString(
workItem.getValue("cm_act_start_date"));
switch(cm_act_start_date){
case null :
break;
default:
var due_date= dojo.date.stamp.fromISOString(
workItem.getValue(workitem_attributes.DUE_DATE));
switch(due_date){
case null :
var return_date= dojo.date.stamp.toISOString(
cm_act_start_date, {milliseconds:true, zulu:true});
return return_date;
break;
default :
var return_date= dojo.date.stamp.toISOString(
due_date, {milliseconds:true, zulu:true});
return return_date;
break;
}
}
}
    });
})();

0 votes



One answer

Permanent link
Since calculated values are overwritten by the calculation, it is a best practice to make them read only. Why would you want to modify a field that is overwritten in any case?

0 votes

Comments

Thank you Ralph for prompted answer. I have not retrieved full detail as why customer would like to leave the field as non readonly.


Is this expected result? As in, is it working as design, or can we still achieve this without having to enable readonly for that field?

I have used calculated values without setting the field to read only in the past, so I think the design should allow this. I have however no information if that is a design intent or if there are exceptions to the rule for certain types. I would check if the dependencies to the attributes you calculate from are set correctly and try it again.

 I have double checked and everything seems to work fine. If dependencies to the attribute I am calculate from are not set correctly, should it not work disregard of "due date" attribute being read only or not?


I am not sure if I am missing something in the script or if there is limitation with particular attribute. I remember reading somewhere that Time spent field had to be set to readonly. Is there anyway to check if same restriction applies for timestamp?

You should only set dependencies to attributes that should trigger the date to be recalculated if they are changed.

I am not aware of limitations, but you could create a work item to get more information.

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: Jul 02 '13, 2:21 a.m.

Question was seen: 5,021 times

Last updated: Jul 04 '13, 2:45 a.m.

Confirmation Cancel Confirm