Hi,
I am trying to figure out how to validate a input param before the user is allowed submit. What I want to do is compare the number of inputs into the array to a number variable. So should validate this:
User input into array = 2 items
Number to verify from = 3 Items
Since numbers don't match an error should pop up. Similar to the "Allow same values" (Attached in picture). I would want a pop up saying "Please add or subtract a value" or soemthing along those lines.
Can this be done?
Thank you
I forgot something:
To have an error message return a string instead of a boolean with something like that:
if (array.length != arrayLength ) {
return "Invalid array length, length must be " + arrayLength ;
}
return "";
Christophe.
This can be done using the custom validation presentation property.
To make it easy create an action returning a boolean with an array and a number as input.
return (array.length == arrayLength);
Then use this action for the custom validation property.
Christophe.
I forgot something:
To have an error message return a string instead of a boolean with something like that:
if (array.length != arrayLength ) {
return "Invalid array length, length must be " + arrayLength ;
}
return "";
Christophe.
This is probably an error due to my lack of programming experience but this is what I have and the error i am getting.
I created the action "HostnameCheck"
I put 2 variables into this action. One is an "array/string" and the other is a "number"
This is the script I put in (copied from above)
if (hostname.length != hostnameExpected ) {return "Invalid array length, length must be " + hostnameExpected ;}return "";After I created the action I went into the "Custom Validation" field and found my action and selected it. This is what is put into the field:GetAction("com.x.library.fullname","HostnameCheck").call( , __NULL__ )When I run the workflow I have this error at the bottom of the screen and unable to select "Submit" (See Pic)This error stays there regardless if the array matches the number
When you set the action for the validation property you need to set its parameters so it will create the string:
GetAction("com.x.library.fullname","HostnameCheck").call(#hostname , #hostnameExpected);
From your string it seems you missed this step.
Christophe.