It's all about the answers!

Ask a question

Calculated script works in Eclipse IDE but not in browser


Soham Saini (112) | asked Jan 05 '16, 2:33 a.m.
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)."

Comments
Dinesh Kumar B commented Jan 05 '16, 4:06 a.m.
JAZZ DEVELOPER

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 commented Jan 05 '16, 5:23 a.m. | edited 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 commented Jan 06 '16, 11:07 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.

One answer



permanent link
Kot T. (1.5k11319) | answered Jan 06 '16, 10:44 a.m.
JAZZ DEVELOPER
See https://jazz.net/library/article/1360 for a technique you can use to debug attribute customization scripts.

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.