Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
11 replies
Subscribers
8 subscribers
Views
5386 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
User Interface
When using a!paragraphField, we have refreshAfter: set to "KEYPRESS".
Jason Ruvinsky
Certified Senior Developer
over 9 years ago
When using a!paragraphField, we have refreshAfter: set to "KEYPRESS". We want to limit the character count in the paragraph field, which works by truncating in the saveInto, and we can provide a live character count in the instructions below, however the user may still enter additional characters into the paragraph, and they don't get cut off until the field loses focus (they tab or click outside of it). Is there any way to immediately reflect the truncated value in the paragraph field while they are typing?
OriginalPostID-142471
OriginalPostID-142471
Discussion posts and replies are publicly visible
0
Mike Schmitt
Certified Lead Developer
over 9 years ago
I think I may have previously implemented something like this with at least some success. Can you post some example code for what you have implemented currently?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Jason Ruvinsky
Certified Senior Developer
over 9 years ago
Example code:
=load(
local!value,
a!paragraphField(
label: ri!label,
value: local!value,
saveInto: {
a!save(ri!output,rule!SAIL_UTIL_limitInputSize(save!value,ri!maxCharacters)),
a!save(local!value,rule!SAIL_UTIL_limitInputSize(save!value,ri!maxCharacters))
},
validations: {
ri!validations
},
required: ri!required,
instructions: ri!instructions& if(and(not(rule!APN_isBlank(ri!instructions)),not(isnull(ri!maxCharacters))),
" ",
""
)&
if(not(isnull(ri!maxCharacters)),
len(local!value) & " of " & ri!maxCharacters & " characters entered. This text field is limited to " & ri!maxCharacters & " characters.",
""
),
readOnly: ri!readOnly,
requiredMessage: ri!requiredMessage,
refreshAfter: "KEYPRESS"
)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Mike Schmitt
Certified Lead Developer
over 9 years ago
Whoops, you're right - it seems that no matter what trickery we do within the saveInto{}, the text / paragraph box won't reflect the changes until focus is lost. This smaller code snippet probably reproduces the issue concisely:
a!textField(
label: "test",
value: ri!text,
refreshAfter: "KEYPRESS",
disabled: len(ri!text) > 5,
saveInto: {
a!save(
ri!text,
left(save!value, 5)
)
}
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sachinr
over 9 years ago
I think its better to show validation for it rather than disabling paragraph field. Your code became like
load(
local!value,
a!paragraphField(
label: ri!label,
value: local!value,
saveInto: {
a!save(ri!output,rule!SAIL_UTIL_limitInputSize(save!value,ri!maxCharacters)),
a!save(local!value,rule!SAIL_UTIL_limitInputSize(save!value,ri!maxCharacters))
},
validations: {
if(len(trim(local!value)>100,"Please enter less than 100 letters.","")
},
required: ri!required,
instructions: ri!instructions& if(and(not(rule!APN_isBlank(ri!instructions)),not(isnull(ri!maxCharacters))),
" ",
""
)&
if(not(isnull(ri!maxCharacters)),
len(local!value) & " of " & ri!maxCharacters & " characters entered. This text field is limited to " & ri!maxCharacters & " characters.",
""
),
readOnly: ri!readOnly,
requiredMessage: ri!requiredMessage,
refreshAfter: "KEYPRESS"
)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Jason Ruvinsky
Certified Senior Developer
over 9 years ago
We don't want to disable the field, obviously, what we want is to stop accepting additional characters while the user is still type (I.e. truncate the string immediately before they leave the field).
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sachinr
over 9 years ago
Use a!save(local!value,leftb(save!value,100)) for saving of that field value. It will truncate string input as you required and maintained its max length to 100.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Mike Schmitt
Certified Lead Developer
over 9 years ago
@sachinr: the issue jason is looking to fix, though, is a way to prevent the user from continuing to type in the text entry box after the size limit has been reached. doing the a!save as you mention does only save the first 100 characters, however it doesn't update the actual contents of the box until they've un-focused. Nothing short of disabling the box actually interrupts the user's input, and disabling is not the desired behavior here. IMHO based on current OOB capabilities, this situation will require compromise on one thing or another.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Jason Ruvinsky
Certified Senior Developer
over 9 years ago
Thanks, all, sounds like it may not be possible. This would be a great enhancement!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Cesar Machuca
Appian Employee
over 9 years ago
I have submitted an enhancement request, and the reference number is AN-59443.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
shivakanthr
over 7 years ago
@jasonr411, Did you find any alternate for this?. We have same requirement.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
>