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

Is there way to set Planned for using calculated value script?

I know the syntax for getting the current state but I need to know what is the syntax to set the Planned for value to a particular iteration. Do we use the iteration name, identifier or id?

0 votes


Accepted answer

Permanent link
Generally you can get the UUID value to set the value like the below.

 
    var type = workItem.getValue(WorkItemAttributes.TYPE); 
 
    if ((type === "defect")) { 
        return "_itagAaMNEeKaNcD4tX8gjw"; 
    } else { 
        return "_itagBKMNEeKaNcD4tX8gjw"; 
    } 


Reference: https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Script_based_calculated_values 

Now you may have a question how to know the UUID value each Planned for ID?

One of ways is creating another script to populate the UUID value into an attribute.

dojo.provide("org.example.Planned_For_ID"); 
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); 
 
(function() { 
var WorkItemAttributes= 
com.ibm.team.workitem.api.common.WorkItemAttributes; 
 
dojo.declare("org.example.Planned_For_ID", null, { 
 
    getValue: function(attributeId, workItem, configuration) { 
        return workItem.getValue(WorkItemAttributes.PLANNED_FOR); 
    } 
}); 
})();

Reference: https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Accessing_built_in_attributes_of


Ralph Schoon selected this answer as the correct answer

3 votes

Comments

You mean declare planner_for var and then set it? Does this format work?

........  var Plannedfor =  workItem.getValue(WorkItemAttributes.PLANNED_FOR);      

......... if (workItem.getValue(WorkItemAttributes.STATE) === "s1")
                {    Plannedfor ="this_time_line";    }
                else                   
                return Plannedfor;                
            }
        });
    })();

No, it won't in JavaScript you have to return the UUID in for IItem type attribute types.

Is't it as simple as . My need is how to set the value for Planned for field in the script

workItem.setValue(WorkItemAttributes.PLANNED_FOR, this_time_line);

Your question has already been answered by @tnakajo pretty much.
You have to find the UUID of the Iteration - by looking at the URL in the browser and then return it. e.g.

  return "_itagAaMNEeKaNcD4tX8gjw"; 

Read https://jazz.net/wiki/bin/view/Main/AttributeCustomization and

  (lab5) carefully and realize that you can't access complex items such as iterations (and other complex things like project areas) in JavaScript and thus you can't search for them by name in JavaScript.

If you want more API and search queries by name you would have to use Java.

Thanks! I really struggled to get the UUID into var without needing another attribute, but I got using another attribute as suggested and its working now

Hi, Uma, I'm happy to see you worked out. I also appreciate Ralph's help.

showing 5 of 6 show 1 more comments

2 other answers

Permanent link
Yes, if you don't want to hard code the UUID and do something more fancy, see https://rsjazz.wordpress.com/2013/06/26/attribute-customization-java-based-value-providers-conditions-and-validators/

The problem I see is that automating planning is likely to produce even more problematic results than if humans do it.

0 votes


Permanent link
OK this is my code,  Can someone help me find how to update the Planned_for section (commented)


dojo.provide("ibm.custom.script.IterationByStatus");
     dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");

     (function() {
         var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
         dojo.declare("ibm.custom.script.IterationByStatus", null, {

             getValue: function(attribute, workItem, configuration) {
             
                             
               var state= workItem.getValue(WorkItemAttributes.STATE);
        console.log(typeof(state))
                    
                 if(state === "com.ibm.team.workitem.taskWorkflow.state.s4")
                 {   workItem.setValue(WorkItemAttributes.PLANNED_FOR, "Recycle Bin");   }
                                   
             }
         });
     })();

0 votes

Comments

I find it quite surprising when you ask questions and then don't consider to apprehend the answers. Your question has been answered already. You can not use the displayname of the iteration, you HAVE to use the UUID of the iteration.

A UUID looks similar to the first answer: "_itagAaMNEeKaNcD4tX8gjw" and you can find the UUID in links or by printing it from the attribute uisng a script. See

  (lab5)

Is there a way to set the UUID derived from the script to a var and use it in my script? I am not sure how acquire the UUID value by printing attribute using a script

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
× 6,121

Question asked: Jul 09 '15, 5:22 p.m.

Question was seen: 3,383 times

Last updated: Jul 13 '15, 11:31 a.m.

Confirmation Cancel Confirm