Hi,
I have a workflow which receives an input string.
In the presentation of this input I defined matching regular expression: ^[^*?=]+$ meaning the string can't contain *?=
It works fine when I run it.
However, when I change the input to Array\String I don't have the option matching regular expression in the presentation.
What is it the best way to verify every strings the user enters?
Thanks!
You don't need to create another input fields. You can pass the field itself to custom validation action assigned to it.
Let's assume your workflow has a single input of type Array/string named myStrings. Create an action with input of type Array/string and return of type string. Then add a 'Custom validation' property to your field in presentation editor, with a value looking something like
GetAction("com.your.module","myaction").call( #myStrings )
where:
com.your.module and myaction - example module name, and respectively action name, of your scripting action for custom validation
myStrings - the name of the input field of type Array/string that will be validated
Submit button will be grayed out automatically in vRO. Don't know about vRA.
Hi,
I don't think you can validate every string within string array chooser component.
One option is to add a 'Custom validation' property to your input array presentation field, and attach an action call to it, but this will do a validation on the whole array after you finish working on it with array chooser, which is not exactly the same as what you want to achieve.
Feel free to open a feature request to support all presentation properties available on singular input fields also on elements of array chooser component, although I don't think such request will get high enough priority right now.
What should i write in the action?
Does the action receive as an input my array string?
And what should it return?
Yes, the action should take as an input your array of strings, and return an empty string if the validation is successful (eg. all elements of the array match some regular expression), or a non-emty string representing the error message to be shown in the presentation.
In the action scripting code, you may iterate over all elements of the array, and for every element check if it is 'valid'/matches your criteria.
so i need to create another input string named: goodStrings and connect the action you described.
The action described can't be connected to the array/string input. Am i right?
Moreover, if the action returns an error, can I grey out the submit botton until the user correct his array/string input?
Is it possible in vra?
You don't need to create another input fields. You can pass the field itself to custom validation action assigned to it.
Let's assume your workflow has a single input of type Array/string named myStrings. Create an action with input of type Array/string and return of type string. Then add a 'Custom validation' property to your field in presentation editor, with a value looking something like
GetAction("com.your.module","myaction").call( #myStrings )
where:
com.your.module and myaction - example module name, and respectively action name, of your scripting action for custom validation
myStrings - the name of the input field of type Array/string that will be validated
Submit button will be grayed out automatically in vRO. Don't know about vRA.
I created the action in the vro as you advised, and from the vro it works.
However, if I use it as an xaas blueprint in the VRA I receive the following error when entering a string:
OGNL invocation error: OGNL: Methos"call" failed for object, TypeError: Cannot find function match in object teststring. (unnamed script#3)
the action:
input: Array/String
ouptput: string
code:
var urlLimit = /^[^*?=]+$/; //no *?= character
for each (var url in urls){
if (!url.match(urlLimit)){
return "Please don't use * ? = character"
}
}
return null;
I changed something in the vro and it works fine also in the vra.
However, in the vra when I enter a string with ?*= characters, I receive an error as expected.
But when I delete this string and write a good string, the error still remains (but I can press submit).
In the vro I don't have this problem. It seems that the error remains in the cache of the my chrome\explorer.
I have vra 7.3
any idea?
It's probably some visual glitch or caching issue in vRA presentations, but I can't tell for sure.
You may want to post this vRA-specific question in vRA community forum as the people who have internal knowledge how the vRA UI stuff works are probably there.