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

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

0 votes

Comments

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.

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);
                }
        }
        }
    });
})();

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
See https://jazz.net/library/article/1360 for a technique you can use to debug attribute customization scripts.

0 votes

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: Jan 05 '16, 2:33 a.m.

Question was seen: 2,220 times

Last updated: Jan 06 '16, 11:07 a.m.

Confirmation Cancel Confirm