It's all about the answers!

Ask a question

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


Uma venkata Lekkala (52419) | asked Jul 09 '15, 5:22 p.m.
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?

Accepted answer


permanent link
Taki Nakajo (1.1k2246) | answered Jul 09 '15, 11:45 p.m.
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

Comments
Uma venkata Lekkala commented Jul 10 '15, 9:47 a.m.

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


Ralph Schoon commented Jul 10 '15, 10:05 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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


Uma venkata Lekkala commented Jul 10 '15, 10:25 a.m.

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


Ralph Schoon commented Jul 10 '15, 10:53 a.m. | edited Jul 10 '15, 10:58 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


Uma venkata Lekkala commented Jul 10 '15, 6:09 p.m.

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


Taki Nakajo commented Jul 12 '15, 9:01 p.m. | edited Jul 12 '15, 9:16 p.m.

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
Ralph Schoon (61.4k33643) | answered Jul 10 '15, 2:09 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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.

permanent link
Uma venkata Lekkala (52419) | answered Jul 10 '15, 1:58 p.m.
edited Jul 10 '15, 2:22 p.m.
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");   }
                                   
             }
         });
     })();

Comments
Ralph Schoon commented Jul 10 '15, 2:51 p.m. | edited Jul 10 '15, 2:58 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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)


Uma venkata Lekkala commented Jul 10 '15, 3:32 p.m.

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


Ralph Schoon commented Jul 13 '15, 11:31 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Your answer


Register or to post your answer.