Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
validating input in workflow instantiation form
Surender
Hi,
I have .wft workflow and I need to validate a user input in workflow instantiation form.
I have a select box which populates all the editions of a branch.
first option contains the hard coded value "Choose Edition".
We are not following a particular format for edition names. So edition name can be any value(Mix of Alpha numeric values).
In workflow form I need to validate, user must choose an edition except "Choose Edition" value.
how can I validate that using "valid_input =>" option in TAG_info section?
Thanks in advance.
Find more posts tagged with
Comments
Migrateduser
RTFM. I'll be the first to say that the Workflow Developer's Guide is a **** document, but it does actually tell you how to do this.
Surender
Thanks Dave.
I can validate if all my editions have specific format like ed_001,ed_002 using valid_input => /ed_.*/ but I dont know what format the selected edition name will be. I only need to make sure that whether the user has selected an edition other than the "Choose edition" value.
Thanks.
Migrateduser
Did you read the part where you can call a function?
Surender
Hi Dave,
Can you point me to the correct page and doc?
I have gone through the TS671 sp1 workflow developer guide, but I didn't find info about how can we call a function and validate the input.
even though if you call a function that function should return a regular expr on form init. valid_input expecting a regex not a 'true' or 'false' value.
but actually my problem is what regex should I return?
is there a way to validate a value which should match other than "Choose Edition" value?
Migrateduser
OK it is a **** document. It doesn't tell you how that works. If you call a function, return "1" if data is valid, and return "0" if data is invalid. How you determine what is valid or not is up tp you. If invalid, the value of error_msg will be displayed next to that input field.
Surender
Thanks Dave.
I did what you have suggested but it seems not working as expected.
Here is my Code:
[html]
TAG_info(
edition =>
[
html => $edition_html,
label => "Choose Edition",
valid_input => validate(),
is_required => "true",
error_msg => "Select Edition name",
],
);
sub validate {
if ($branch_path =~ /abc\/xyz/) {
print DEBUG "Here1 \n";
my $edtn_val = __VALUE__('edition');
print DEBUG "edtn_value : $edtn_val\n";
if ($edtn_val =~ m/ChooseEdition/ ) {
print DEBUG "IF \n";
return "0";
}
else {
print DEBUG "ELSE \n";
return "1";
}
}
esle {
return "/ed_.*/";
}
}
[/html]
Here is my debug output:
[html]
Here1
edtn_value : ChooseEdition
IF
[/html]
It was inside if loop and returning "0" and I tried without quotes return 0;
But it doesn't display error message?
Am I doing anything wrong here?
Adam Stoller
It should be just:
return 0;
(no quotes) - however, I think you're approaching this wrong.
Instead of a text field - you should write code that runs
iwlist
branch_path
/EDITION
and format the results into a select list for the user to choose from - make sure that the first entry in the list is "Choose Edition" with a value of "" (empty string) - as long as you make the item required you shouldn't have to put any other validation code in there.
Surender
Thanks Ghoti. I got it.
Instead of empty string I was adding some value(ChooseEdition).
Thnaks again Dave and Ghoti.