I am looking for code to have a paragraph field which should allow user to enter multiple phone numbers, each number should be in a separate line without any separator like semicolon (it is like when we create APPIAN Constant for text/number array, the paragraph will take each value in a separate line. I do also need the same). Please let me know if you idea about it.
Thanks,
Shanmugapriya K
Discussion posts and replies are publicly visible
Hello Shanmuhapriyak,
As per my understanding you are able to enter multiple phone number in a paragraph field but when you display it is showing in single text without <br> and if that is the case then you can use below code to achieve the requirement.
load( local!phonenumber, a!formLayout( contents: { a!paragraphField( label:"phone number" & local!phonenumber, value:local!phonenumber, saveInto: local!phonenumber ), a!richTextDisplayField( value: a!richTextBulletedList( items: a!forEach( items: local!phonenumber, expression: a!richTextItem( text: fv!item ) ) ) ) }))
Thanks Aswin.
Not to display, but when user enters phone numbers then that should be stored it in array format. Need to do validation for each phone number to verify it has all digits only phone number doesn't exceed 10.
In paragraph field, though if i use text array to store the user entered phone numbers(without semicolon) then the count of variable(count(local!phonenumber)) is just 1.But i want to store value in array format though user enters without semicolon.
you can use below code to achieve the case where user needs to press enter after entering every 10 digit so we can replace the space with ; sing split function
code below
load( local!phonenumber, a!formLayout( contents: { a!paragraphField( label: "phone number" & local!phonenumber, value: local!phonenumber, saveInto: local!phonenumber ), a!textField( value: if( rule!APN_is_Blank(local!phonenumber), {}, split(local!phonenumber,char(10))) ) } ))
It worked, thank you so much.
Mark the answer as green as to other people will also benefit from it
As an additional suggestion, the following recipe can be used to do the splitting into an array before even saving the string to the local variable. This way you can easily do a validation as needed on each individual line.
a!localVariables( local!numbers: {}, a!paragraphField( placeholder: "Enter individual numbers separated by a newline.", value: joinarray(local!numbers, char(10)), saveInto: { a!save( local!numbers, split(save!value, char(10)) ) } ) )
Thanks Mike.