Calculated script works in Eclipse IDE but not in browser
I wrote a calculated script on Closed by, which auto populates the Closed By field by the person who closes the defect. The script works fine in Eclipse but when I perform the same steps I get the error as :"Attribute 'Closed By' not set.The 'Closed By' attribute needs to be set (work item XXXXXX)."
Steps followed.
1. User B, Created a workitem.
2. Transitioned the workitem to Verify state.
3. Value of Closed by is either Unassigned OR User A.
4. User B closes the defect.
5. In Eclispe->Closed BY is auto populated by User B.
In Browser -> Get the error
Attribute 'Closed By' not set.The 'Closed By' attribute needs to be set (work item XXXXXX)."
Steps followed.
1. User B, Created a workitem.
2. Transitioned the workitem to Verify state.
3. Value of Closed by is either Unassigned OR User A.
4. User B closes the defect.
5. In Eclispe->Closed BY is auto populated by User B.
In Browser -> Get the error
Attribute 'Closed By' not set.The 'Closed By' attribute needs to be set (work item XXXXXX)."
Comments
Dinesh Kumar B
JAZZ DEVELOPER Jan 05 '16, 4:06 a.m.Hi Soham,
I feel something within the script is causing this...
have you tried using firebug or chrome debugging to see if the script returns any error on web browser..
if you could share the sample script.. it may be easier to understand.
Soham Saini
Jan 05 '16, 5:24 a.m.dojo.provide("com.ibm.team.worktiem.getClosedBy");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
var scriptname ="getClosedBy";
var doDebug = true;
var modifiedBy ="";
dojo.declare("com.ibm.team.worktiem.getClosedBy", null, {
getValue: function(attribute, workItem, configuration) {
var currentState = workItem.getValue(WorkItemAttributes.STATE);
var closedBy = workItem.getValue("closedby");
var workitemType = workItem.getValue(WorkItemAttributes.TYPE);
modifiedBy = workItem.getValue(WorkItemAttributes.MODIFIED_BY);
if(workitemType=="defect")
{
if(currentState =="Closed")
{
// return the rtc user who modified the last
return modifiedBy;
}
else
{
//return existing value, so no change
return closedBy;
}
}
function debug(display){
if(doDebug){
console.log(scriptname + ": " + display);
}
}
}
});
})();
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Jan 06 '16, 11:07 a.m.You can not not return something. In the case of !(workitemType=="defect") you don't return a value - this makes the script syntactically incorrect.
You could return the value the attribute has in this case.