Using a script to set a calculated priority value
Hello, I am trying to set an attribute customization in rqm using a script.The script is supposed to get the input on a defect work item for the severity attribute and a custom risk attribute. The severity and priority enumerations and attributes in rqm have not been adjusted. The priority attribute should calculate is value using the logic in the script. I have been able to return the priority back out to my defect , and rqm shows the returned value in a query. However my dashboard widget is showing the literal priority categories instead of the high,medium,low enumerations.I think this might be an indexing issue.Any help is appreciated.
Here is the script:
dojo.provide("com.example.Priority");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.example.Priority", null, {
getValue: function(attribute, workItem, configuration) {
//Output to log line break mostly just to break it up for viewing
console.log("***************************************************************************************************************************************");
//Logs value for parameters entered in, note may have to adjust enumerations for priority to non read only to actually get a value
//Priority is really only there for setting up the script, leave it commented out unless you need it
try{
var risk = workItem.getLabel("risk");
console.log(risk);
var severity = workItem.getLabel("internalSeverity");
console.log(severity);
var priority = workItem.getLabel("internalPriority");
console.log(priority);
}
catch (err){
var txt;
txt="Something went wrong";
txt+=" You should fix that";
alert(txt);
}
// Comparison statements for Risk/severity values and set priority value, use log entry values from above for actual inputs and outputs, than return priority back to rqm
// Using the values from priority above so that the conversion back into rqm is correct
if (risk === 'High' & severity === 'Minor' ){
internalPriority = 'priority.literal.l8';
}else if (risk === 'High' & severity === 'Major' ){
internalPriority = 'priority.literal.l9' ;
}else if (risk=== 'High' & severity === 'Critical' ){
internalPriority = 'priority.literal.l7' ;
}else if (risk === 'Low' & severity === 'Minor' ){
internalPriority = 'priority.literal.l2' ;
}else if (risk === 'Low' & severity === 'Major' ){
internalPriority = 'priority.literal.l8' ;
}else{
internalPriority = 'priority.literal.l9' ;
}
return internalPriority
}
});
})();
Here is what the widget is showing.
Here is the script:
dojo.provide("com.example.Priority");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.example.Priority", null, {
getValue: function(attribute, workItem, configuration) {
//Output to log line break mostly just to break it up for viewing
console.log("***************************************************************************************************************************************");
//Logs value for parameters entered in, note may have to adjust enumerations for priority to non read only to actually get a value
//Priority is really only there for setting up the script, leave it commented out unless you need it
try{
var risk = workItem.getLabel("risk");
console.log(risk);
var severity = workItem.getLabel("internalSeverity");
console.log(severity);
var priority = workItem.getLabel("internalPriority");
console.log(priority);
}
catch (err){
var txt;
txt="Something went wrong";
txt+=" You should fix that";
alert(txt);
}
// Comparison statements for Risk/severity values and set priority value, use log entry values from above for actual inputs and outputs, than return priority back to rqm
// Using the values from priority above so that the conversion back into rqm is correct
if (risk === 'High' & severity === 'Minor' ){
internalPriority = 'priority.literal.l8';
}else if (risk === 'High' & severity === 'Major' ){
internalPriority = 'priority.literal.l9' ;
}else if (risk=== 'High' & severity === 'Critical' ){
internalPriority = 'priority.literal.l7' ;
}else if (risk === 'Low' & severity === 'Minor' ){
internalPriority = 'priority.literal.l2' ;
}else if (risk === 'Low' & severity === 'Major' ){
internalPriority = 'priority.literal.l8' ;
}else{
internalPriority = 'priority.literal.l9' ;
}
return internalPriority
}
});
})();
Here is what the widget is showing.
Comments
Donald Nong
May 06 '16, 1:30 a.m.Re-post the attachment so that others can see.