It's all about the answers!

Ask a question

Set value of enum with calculated script


Sany Maamari (13243851) | asked Feb 14 '17, 10:31 a.m.
edited Feb 14 '17, 10:36 a.m. by Ralph Schoon (63.6k33647)

 Hello, 

After succeding in getting value from enum, I'm now trying to set a calculated value into an enum

I'm using 
workItem.setValue(attributeId, enumLiteral);

It works, but the value isn't changed on the fly. It is changed only after saving the workitem.
Is it possible to make it change on the fly when we change the value of another enum without saving the WI ? 

Thank you for your help


Comments
Sunny Kumar commented Jan 19 '23, 8:00 a.m. | edited Jan 19 '23, 8:01 a.m.

 Hi Sany,


I have a similar requirement to what you have stated, It would helpful if you can share some knowledge on this


David Honey commented Jan 19 '23, 12:41 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Gagan Kumar there is already an accepted answer to this question provided almost 6 years ago. If you have new questions to ask, please post your own question.

Accepted answer


permanent link
Dinesh Kumar B (4.1k413) | answered Feb 14 '17, 11:48 p.m.
JAZZ DEVELOPER

Hi Sany,

instead of workItem.setValue, try applying the calculated value script directly onto the attribute, just return the value from the script.  the returned value would directly get set onto the attribute then.  this should show the changes as soon as the dependent attribute is changed.

if you are using the same script to set multiple enum attributes, you could try a conditional return as in :
    if (attributeId === "enumattributeid_1")
         return "literalidapplicablefor_1"
    if (attributeId === "enumattributeid_2")
         return "literalidapplicablefor_2"
so on...

Sany Maamari selected this answer as the correct answer

Comments
Sany Maamari commented Feb 15 '17, 4:33 a.m.

 Yes it works, Thanks

Your answer


Register or 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.