oscaralvarez
Enthusiast
Enthusiast

hide/show input parameters if a substring is found on another input parameter

Jump to solution

Hello

I know there is a way to hide/show input parameters to the user depending on another value by using the following, which it's pretty useful and i use it a lot.

we enter someting like this in the pencil field :  #input_variable == "expected value"

But now i need to find also when when a substring is found!

something like :

#input_variable == "*substring*"

#input_variable == ".*substring.*"

#input_variable.indexOf("substring")

Tried all that, but nothing works :smileyplain:

Does this really can be done in some way??

Oscar

1 Solution

Accepted Solutions
oscaralvarez
Enthusiast
Enthusiast

Finally I found this solution that works fine

#VARIABLE.matches("(?i).*SUBSTRING.*")?true:false

I hope it's useful for some one.

Oscar

View solution in original post

0 Kudos
4 Replies
eoinbyrne
Expert
Expert

There's probably an OGNL expression that can give you the result of String.substring or String.indexOf but you could just create an action which does the comparison and returns the boolean you want? If you click the purple Jigsaw piece on the far right you'll get an Action selector view and you can choose the action there.

The Show/Hide presentation modifiers both require a boolean result for their evaluation so make sure the action returns boolean

HTH

poorem
Enthusiast
Enthusiast

I've used some of that OGNL syntax before too, like you for fixed values e.g.

#vmType.toLowerCase() == "managed"

I'm not sure if wildcard characters will work but an alternative is to make a simple action that does the job and use that:

GetAction("com.mycompany.vropresentationlogic","checkForSubstring").call( #input_variable , "substring" )

The action would just need to return a boolean

0 Kudos
iiliev
VMware Employee
VMware Employee

Hi,

OGNL expression should be

#input_variable.indexOf("substring") != -1

The above will evaluate to true if the input_variable value contains substring (assuming input_variable is input parameter/attribute of type string).

0 Kudos
oscaralvarez
Enthusiast
Enthusiast

Finally I found this solution that works fine

#VARIABLE.matches("(?i).*SUBSTRING.*")?true:false

I hope it's useful for some one.

Oscar

0 Kudos