Hi all,We have a business requirement where the user will enter data into a text field and if the data reaches a certain character limit say 100, we should not allow users to type more than 100. Like they want it to be freezed or stopped at 100 character length? We are showing character limit validation but they want some kind of restriction. Is it possible to achieve to such feature?
Discussion posts and replies are publicly visible
No, you cannot prevent the user from continue typing.
In case this is a deal breaking requirement, which I have my doubts on, this would call for a custom component plugin.
You can try using the below code:
a!localVariables( local!description, a!textField( label: "Description", instructions: "You can only add 100 characters in this field, system will auto trim the characters after 100th character", value: local!description, saveInto: { a!save(local!description, left(save!value, 100)) } ) )
This way it will never throw the validation but auto trim the characters after 100.
Stefan Helzle ,custom component plugin means something we should build or are they already available in app market?Plus, its not like a deal breaking requirement, just they are expecting something more out of appian
Harsh Kumar Agarwal , we tried the same but you can enter the data after 100 also. Unless there is a key press, it will continue to allow and only when a key is pressed, the save will execute and that is something which business wont accept.
I do not suggest to go that route, but to push back that "requirement".
And yes, you would have to build that yourself.
Everybody has its own set of expectations, but Appian cannot make everybody happy ;-)
Got it. Thanks Stefan Helzle
This is a really specific case
You can discuss with business why they want it specifically and then push back explaining the behaviour of Appian components.
I have found it LARGELY sufficient to simply utilize Appian's newer, built-in "character limit" functionality with "show character limit" turned ON.
It does not physically STOP users from entering more characters than the limit, but it is VERY visible and makes it VERY easy for the user to comply.
If you MUST have something like you describe (which i'd be curious to hear the business owners' rationale behind), then a solution like HARSH posted above but with "refresh after keypress" turned on, will be your closest option. It won't work perfectly though. (You can use the character limit visibility to your advantage here too).
Edit: actually "refresh on keypress" doesn't help a whole lot here - either way, here's my revised code (shortened the limit temporarily for easier testing)
a!localVariables( local!description, local!limit: 20, a!textField( label: "Description", instructions: "You can only add " & local!limit & " characters in this field, system will auto trim the characters after 100th character", value: local!description, refreshAfter: "KEYPRESS", characterLimit: local!limit, showCharacterCount: true(), saveInto: { a!save(local!description, left(save!value, local!limit)) } ) )
We did the same Mike Schmitt . This is the closest we can go but it does not seem that much convincing to the business. They are expecting like a hardstop which they are comparing it with some other UI from some external system which is not possible in appian. As Stefan suggested, we will push back the requirement.