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

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.



0 votes

Comments



Re-post the attachment so that others can see.



One answer

Permanent link
 Hi Jeff,

Which RQM version and which widget are you using?

0 votes

Comments

4.0.7, I was actually able to get this to work. ThanksĀ  anyways.

For the benefit of the community, can you please let us what changes you have made to make it work?

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
× 12,019

Question asked: Apr 29 '16, 1:08 p.m.

Question was seen: 2,218 times

Last updated: May 06 '16, 1:31 a.m.

Confirmation Cancel Confirm