VMware Cloud Community
mg1978
Enthusiast
Enthusiast
Jump to solution

Matching reqular expression in the workflow presentation

Hi All,

I try to configure a input parameter in the presentation. I will use the "Matching reqular expression" function to allow an input only with this characters which I will.

The customer can but doesn´t must put all the characters, but he cannot put any others characters.

I use the following value  ValidationExpression="^([a-zA-Z0-9_\.\s\-]*)$"  , but it doesn´t work.

for example:

I have an input parameter "Application Name" and the customer should could put the name "HR SQL Server - June 2012" or  "HR SQL Server", but they shouldn´t could put a name like "HR´s SQL Server - June 2012".

Have somebody an idea for the value or a solution.

Reply
0 Kudos
1 Solution

Accepted Solutions
cdecanini_
VMware Employee
VMware Employee
Jump to solution

I did it for you. The action:

Screen shot 2012-06-20 at 4.01.22 PM.png

The workflow calling the action:

Screen shot 2012-06-20 at 4.03.35 PM.png

The workflow run.

Screen shot 2012-06-20 at 4.06.39 PM.png

Screen shot 2012-06-20 at 4.06.54 PM.png

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter

View solution in original post

Reply
0 Kudos
9 Replies
cdecanini_
VMware Employee
VMware Employee
Jump to solution

The syntax must be the one compatible with OGNL.

When I cannot figure it out quickly enough I create an action that I use with the presentation property "Custom validation". Example to validate an IP address:

if (!ip.match(new RegExp("^((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})$"))) {
         return "Invalid IP! (" + ip + ")";
     }

return null;

The advantage of using actions:

  • you can set a scripting module (an action category) with all the actions to validate fields and reuse these.
  • it is plain javascript with tons of examples available online
  • easier to maintain
  • you can export it / import / share it

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
Reply
0 Kudos
mg1978
Enthusiast
Enthusiast
Jump to solution

Hi,

This with the action is very good.

It is possible to create a action or scripted task which have an input parameter where the customer put a text and an output attribute where the text is in special format and without any spectial characters.

For example:

InputParamter -> CustomerApplicationName = HR´s SQL Server - 20.06.2012

OutPutAttribute -> ConsolidatedApplicationName = HR SQL Server - 20.06.2012

or

InputParamter -> CustomerApplicationName = Martin´s AppWorld - 20.06.2012 $TestApplication#

OutPutAttribute -> ConsolidatedApplicationName = Martin AppWorld - 20.06.2012 TestApplication

Reply
0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

Sure, just set the action to return a string and have a string imput parameter and use the action with the default value presentation property with passin gthe first input field as the action parameter.

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
Reply
0 Kudos
mg1978
Enthusiast
Enthusiast
Jump to solution

Hi,

Do you have an example for me how I can set a string as a return ?

Reply
0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

Just edit the action and set set the return type.

Screen shot 2012-06-20 at 2.56.05 PM.png

And here is how you call it (the string is generated automaticaly with using the action icon on the right)

Screen shot 2012-06-20 at 3.02.53 PM.png

Here it is a custom validation. If you want to set a field default value, use the Default value presentation property.

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
Reply
0 Kudos
mg1978
Enthusiast
Enthusiast
Jump to solution

Hi

I create a action

2064256.png

and a small Workflow

I run this workflow with special charecters, but I get the special characters in the output "NameResult"

Reply
0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

I would expect it to do it since ! means not in javascript.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
Reply
0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

I did it for you. The action:

Screen shot 2012-06-20 at 4.01.22 PM.png

The workflow calling the action:

Screen shot 2012-06-20 at 4.03.35 PM.png

The workflow run.

Screen shot 2012-06-20 at 4.06.39 PM.png

Screen shot 2012-06-20 at 4.06.54 PM.png

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
Reply
0 Kudos
mg1978
Enthusiast
Enthusiast
Jump to solution

Thank you very much

It is working very good and for what I need this.

Reply
0 Kudos