How to get a calculated value script to store a timestamp into an attribute ?
First time using script based provider. Spent almost a day on it, still couldn't get it to work yet?
We have a small string attribute for date&time in text (validated with a regular expression) with a timestamp attribute as its dependency.
Eventually we will want to convert the text time into a timestamp to store in the TS attribute. But for now, as we kept failing to get it to work, we are just trying to:
dojo.provide("com.acn.dor.scripts.validators.StoreTextTimeAsTimestamp");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.date");
dojo.require("dojo.date.stamp");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
var StoreTextTimeAsTimestamp = dojo.declare("com.acn.dor.scripts.StoreTextTimeAsTimestamp", null, {
getValue: function(attributeId, workItem, configuration) {
// var dateTimeString = workItem.getValue(WorkItemAttributes.com.acn.adt2.workitem.attribute.custom1_defect);
var dateTime = dojo.date.stamp.fromISOString(new Date(), {milliseconds:true, zulu:true});
return dateTime;
}
});
})();
|
One answer
Ralph Schoon (63.7k●3●36●48)
| answered Mar 26 '14, 8:24 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I don't see a description what happens or what does not. Supposing your script is syntactically correct, the one thing you would have to do, is to set the dependency to the attribute that, when changed, would trigger the script and thus setting the calculated attribute (referred to as txt). You can only react on change of the attribute. When the attribute is changed, the calculated value is triggered. Just saving the work item would not trigger the calculated value.
You might want to look into https://jazz.net/library/article/1093 Lab 5 for some more hints on JavaScript. Comments
long TRUONG
commented Mar 26 '14, 8:45 a.m.
What we'd like to achieve is:
Do we make txtAttrib a dependency of TSattrib ? or vice versa ? We had tried both ways actually, neither works.
Nothing get stored in TSattrib.
Ralph Schoon
commented Mar 26 '14, 9:26 a.m.
| edited Mar 26 '14, 9:26 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
To trigger the calculated value for TSattrib, you need to add a dependency to txtAttrib to TSattrib. This will trigger the calculated value script when txtAttrib changes.
|
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.