Skip to main content
5-Regular Member
September 6, 2024
Solved

Set a dropdown field with "Computed as"

  • September 6, 2024
  • 2 replies
  • 1998 views

Does anyone know the correct syntax to set a dropdown field using the "Computed as" logic? For example if I want to automatically set a dropdown to option id 1, how would I do that? I have tried several things, such as choiceField[2][1], choiceField[2][0]_option[1], etc, from the Codebeamer documentation but nothing seems to work.

Best answer by Nico_M

Dear Chris,

 

Sorry my bad, forgot one crucial thing:

  • As every choiceField is also a collection (even if its single-choice), you need to put a List() around your computed option, so in your example:
  • List(choiceList[4]_$option[1])

Let me know if that does the trick 🙂

 

Cheers,

 

Nico

 

2 replies

10-Marble
September 9, 2024

Hi,

 

The syntax is <propertyNameofTheChoiceField>_$option[<optionID>]

So for example if you want to calculate that the field choiceList[1] should have the 2nd option selected by computation, this would be the syntax:

choiceList[1]_$option[2]

 

This is also described here in the documentation (just not indexed well in the table of contents): https://codebeamer.com/cb/wiki/25722#section-Context+Variables

 

Hope this helps,

 

Cheers,

 

Nico

5-Regular Member
September 9, 2024

Hey Nico,

 

Thank you for your reply.

 

I have tried the syntax you have mentioned from the documentation. This does not allow me to save the changes to the field. I get an error: 

 

Compiling "choiceList[4]_$option[1]" to compute "Validated Cycle/Vendor (AMISC1-6)" failed: "Cannot convert of type class com.intland.codebeamer.persistence.dto.ReadOnlyChoiceOptionDto to interface java.util.List" Please save the tracker configuration before you use newly added fields in expressions.

CM_9399659_0-1725887895020.png

 

Do you have any idea why this might be?

 

Chris

Nico_M10-MarbleAnswer
10-Marble
September 9, 2024

Dear Chris,

 

Sorry my bad, forgot one crucial thing:

  • As every choiceField is also a collection (even if its single-choice), you need to put a List() around your computed option, so in your example:
  • List(choiceList[4]_$option[1])

Let me know if that does the trick 🙂

 

Cheers,

 

Nico

 

Catalina
Community Moderator
September 12, 2024

Hi @CM_11253122,

 

Only the author of the topic, in our case @CM_9399659, can mark a reply as the Accepted Solution.

 

Thanks!

Catalina | PTC Community Moderator