TomBridges
TomBridges

Reputation: 53

velocity: how to find out if a field value contains a certain string

New to velocity and need some help. I'm getting a field value:

#set($value2 = $customFieldManager.getCustomFieldObject("customfield_10010").getValue($issue))

But now want to check if $value2 contains a certain string, for example abc.

How do I do this?

Upvotes: 0

Views: 3522

Answers (2)

ruturaj solanki
ruturaj solanki

Reputation: 21

We can use contains to check value is in array as well

#if( $arrayName.contains($value) )
     <p>$value</p>
#end

Upvotes: 1

Oldskultxo
Oldskultxo

Reputation: 965

I would use

#if($value2.contains("abc"))
    <p>display something, for example</p>
#end

just like you would do in java;

Regards

Upvotes: 1

Related Questions