It's all about the answers!

Ask a question

Set value of enum with calculated script


Sany Maamari (13243150) | asked Feb 14 '17, 10:31 a.m.
edited Feb 14 '17, 10:36 a.m. by Ralph Schoon (61.5k33643)

 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
Gagan Kumar commented Jan 19, 8:00 a.m. | edited Jan 19, 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, 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.