converting enum to string or String to enum

0
hi How can i convert an enum to string or String to enum in the xpath contraint
asked
3 answers
6

It also depends on which part of the enumeration you want to compare.

In Xpath enumerations match a string value, in actions you can use getCaption and getKey value to compare against strings.

parsing an enumeration based on a string value can be done by creating an enumeration variable that has something like the following content:

Enum {1,2,3}

if inputString = '1'
then 1
else if inputString = '2'
then 2
else if inputString = '3'
then 3
else empty
answered
3

Daniel -

Enumeration keys and captions are both strings.  In order to get the caption value, you would use GetCaption.  In order to get the Key value, you could use getKey.  

In the example you put in your comments, you are comparing the Caption on the left side of the equation to the enumeration value (or key) on the right hand side of the equation.  To make this if statement work, either compare caption or key on both sides of the equation.

However, in looking at your example, if you want to display an enumeration value in a message box, you could do that by using getCaption($v_EnumActivityMode) as the literal for your string argument.  I don't think you need an if statement to display W or N in the message box.  If you want to display the key in your message box, use getKey($v_EnumActivityMode).  

You can find documentation on these two functions here.

Hope that helps,

Mike

answered
0

How are you looking to use it? Typically when you want to X Path using an enumeration it's as simple as:

Entity/attribute = 'String Value'

answered