It's all about the answers!

Ask a question

Set automatically enum literal using Calculated Value script

Veronica Alvarado (116) | asked Aug 22 '18, 7:35 p.m.
edited Aug 22 '18, 7:42 p.m.

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:


(function() {
    var WorkItemAttributes=;
    dojo.declare("org.example.ClearOnValue", null, {
getValue: function(attributeId, workItem, configuration) {
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.

2 answers

permanent link
Veronica Alvarado (116) | answered Aug 23 '18, 7:21 p.m.

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.


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

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



     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.


permanent link
Ralph Schoon (62.9k33645) | answered Aug 23 '18, 3:00 a.m.
  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. 

Your answer

Register or to post your answer.