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

Set automatically enum literal using Calculated Value script

Hello,

I'm trying to set automatically an "Unassigned" literal in my Application enum if work item status is "Failed". When I move to Failed status, ID literal is add as new value in the enum.

This is the script that I have created:

dojo.provide("org.example.ClearOnValue");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");

(function() {
    var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
    dojo.declare("org.example.ClearOnValue", null, {
getValue: function(attributeId, workItem, configuration) {
try{
var state= workItem.getValue(WorkItemAttributes.STATE);
if (state == "bugzillaWorkflow.state.s10") // State ID
return "com.sw.att.pc.enum.application.literal.l2"; // Literal ID for Unassigned value
}
// else return the selected value
return workItem.getValue("testAttribute.application);
}
catch(err) {
console.log("Error ClearOnValue: " + err.message);
}
}
});
})();

I have review the following links:


In my Application attribute, I assigned my script and status attribute as dependency.

Can you help me to know if I need to configure any ?

Thanks for your help.

0 votes



2 answers

Permanent link
  1. There is no real question in your question. What is the question?
  2. The line: return workItem.getValue("testAttribute.application); is missing a closing apostrophe.
  3. Scripts can only read the current state. They can not determine a state change, so your script will only ever do anything after you save a state change. 

0 votes


Permanent link

Hi Ralph,

Thanks for your reply.

I review all the lines into my script and I had these errors:

1.      As you commented, I added the closing apostrophe in this line:

    return workItem.getValue("testAttribute.application");

2.      I put a wrong ID for "Unassigned" literal.

    Before:

    if (state == "bugzillaWorkflow.state.s10") {

 return "com.sw.att.pc.enum.application.literal.l2";

    }

    After:

     if (state == "bugzillaWorkflow.state.s10") {

            return "com.sw.att.pc.enum.applicacion.literal.l8";

     }

My question was why the returned literal (ID) was being added as a new literal. This was happening because the ID was wrong for “Unassigned” value.

Thanks for your help.

Regards

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
× 7,496
× 6,122

Question asked: Aug 22 '18, 7:35 p.m.

Question was seen: 1,987 times

Last updated: Aug 23 '18, 7:21 p.m.

Confirmation Cancel Confirm