in a paragraph field i will provide input as
test1
test2
test3
How this data will be stored in db ,is it will be in line by line as separate string or as a single string
Discussion posts and replies are publicly visible
If I understood correctly, you want to store these as separate line items in the DB but have them in one paragraph field in the interface?
yes Mathieu Drouin
Not sure why. I am not getting any errors for the same email address. Could you please share your rule/local variable section with the data. and what is the type for the rule input.
Konduru Chaitanya : emailaddresses is a text type in CDT
if i add space after emailaddress then i'm not getting any error ,what is need of adding space
Harshit Bumb (Appyzie) said:a!forLoop()
:raises eyebrow:
Even if calling split() and passing in a *literal linebreak* as the delimiter works (i'd say by accident here), i would strongly advise against this approach as it's not going to be very reliable and, as you can guess from the exchange here, might not be copied over correctly by others.
Instead just do: "split(local!emails, char(10))".
Mike Schmitt I agree. Didn't think of it and yeah the literal line break was me being clumsy I had copied from the previous code I mentioned above. I didn't format.
Konduru Chaitanya :can you please explain why we are using substitute and tostring that part in code
Here's a similar but alternative approach I just typed up, for what it's worth:
a!localVariables( local!emailParagraphText, local!individualEmails: if( a!isNotNullOrEmpty(local!emailParagraphText), a!forEach( split(local!emailParagraphText, char(10)), if(a!isNotNullOrEmpty(fv!item), fv!item, {}) ), {} ), local!invalidEmails: a!flatten(a!forEach( local!individualEmails, if( validateemailaddress(fv!item), {}, fv!item ) )), a!paragraphField( label: "emails", value: local!emailParagraphText, saveInto: { a!save( local!emailParagraphText, clean(save!value) ) }, validations: { if( a!isNotNullOrEmpty(local!invalidEmails), "Invalid emails entered: " & joinarray(local!invalidEmails, ", "), {} ) } ) )
will these data also be saved in db as line by line?
ZAINAB said:will these data also be saved in db as line by line?
You're getting ahead of yourself a little bit. None of this will affect how the data is saved to the DB either way, that is completely separate processing that would need to happen later. You should work to understand this step fully before moving on to worrying about the DB structure issues.