I want emails in array format like {"test@test.com", "test2@test.com" }
a!localVariables( local!data: ri!test_Requests, local!rawEmails: ri!test_Requests.emailAddresses, local!individualEmails: reject( a!isNullOrEmpty(_), a!forEach( items: split(local!rawEmails, char(10)), expression: trim(fv!item) ) ), local!invalidEmails: reject( a!isNullOrEmpty(_), a!forEach( items: local!individualEmails, expression: if( regexmatch( pattern: "^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$", searchString: fv!item, regexFlags: "si" ), null, fv!item ) ) ), local!formattedEmails: "{" & joinarray(local!individualEmails, """,""") & "}", local!validationMessage: if( a!isNotNullOrEmpty(local!invalidEmails), "Emails must be valid and each on a new line.", {} ), a!formLayout_25r1( label: "Test", contents: { a!sectionLayout( contents: { a!columnsLayout( columns: { a!columnLayout( contents: { a!boxLayout( label: "", labelSize: "SMALL", contents: { a!columnsLayout( columns: { a!columnLayout( contents: { } ), } ), a!paragraphField( label: "Email Addresses", labelPosition: "JUSTIFIED", placeholder: "Email Addresses should be one per line (can be pasted from Excel)", value: local!data.emailAddresses, saveInto: { a!save( local!data.emailAddresses, lower(save!value) ), a!save( ri!test_Requests.emailAddresses, lower(save!value) ) }, refreshAfter: "KEYPRESS", height: "TALL", required: true, requiredMessage: "Email Address is Required", validations: if( ( a!isNotNullOrEmpty(local!invalidEmails) ), "Emails must be in a valid format, and each email must be on a new line. ", {} ) ), a!cardLayout( contents: { a!textField( label: "The following emails could not be resolved against (or were linked to multiple) active employee records:", value: joinarray( a!forEach( items: split(ri!incorrectemails, ";"), expression: trim(fv!item) ), char(10) ), readOnly: true() ) }, showWhen: ri!HasError = true(), style: "INFO", marginAbove: "NONE", marginBelow: "LESS", accessibilityText: "Information message" ), a!cardLayout( contents: { a!richTextDisplayField( value: { a!richTextItem( text: "error:", style: "STRONG", size: "STANDARD" ), char(10), a!forEach( items: ri!emailRestrictions, expression: a!richTextItem( text: { "EmployeeName: " & index(fv!item, "fullName", null) & " " & " error : " & index(fv!item, "restrictionName", null), char(10) } ) ) } ) }, accessibilityText: "Information message", style: "INFO", showWhen: ri!hasRestriction = true() ) }, style: "#134f5c", marginBelow: "STANDARD" ) } ) } ) } ) }, buttons: a!buttonLayout( primaryButtons: { a!buttonWidget_23r3( label: "Submit", style: "PRIMARY", submit: true, validate: true(), saveInto: { a!save( ri!FormattedEmails, joinarray( a!forEach( items: local!individualEmails, expression: char(34) & fv!item & char(34) ), "," ) ) , a!save( ri!test_Requests.emailAddresses, local!rawEmails ), a!save(ri!test_Requests.isActive, true()) /*a!save(ri!test_Requests.employeeIDs,index(ri!Result.body,"values",null()))*/ }, loadingIndicator: true() ) }, secondaryButtons: { a!buttonWidget_23r3( label: "Cancel", style: "NORMAL", submit: true, validate: false, value: true, saveInto: ri!cancel ) } ) ) )
Discussion posts and replies are publicly visible
Replace the code of a!save() in line 150 as below and see if it suits what you are expecting.
a!save(ri!FormattedEmails, concat("{",joinarray( a!forEach( items: local!individualEmails, expression: char(34) & fv!item & char(34) ), "," ),"}"))
Do you want this in JSON format? If yes, use toJson() to transform the list in your local!individualEmails in line 150.
Harsha Sharma In process variable it is coming as "{"test@test.com","test2@test.com"}"
I need to pass {"test@test.com","test2@test.com"} this value as input to an expressionrule because of extra " " at begin & end it is not returnign the values.
Replace your saveInto with:
a!save( ri!FormattedEmails, local!formattedEmails )
You already built local!formattedEmails correctly at the top.
In an expression you will see an extra " " at beginning and end but when passed into process model to a text type variable the value will be {"test@test.com","test2@test.com"} without the quotes. So save the changes and then check at runtime you will not see any extra quotes.
Can you clarify what your use case is, exactly? As in, why do you feel you need *that exact format*?
I think what's missing, and what the other responses have missed so far, might be the fact that the Appian "text array" type is not represented visually in a consistent manner, as it's displayed slightly differently depending on whether you're looking at in-process data, data shown in a text/paragraph field, data shown in an expression output, or data shown in an "expressionable" manner i.e. what can be used in an expression to cause that array of data to be loaded / sent elsewhere / output. And if you don't understand the difference between all of these ways, it will probably seem confusing (like you think you're not getting an "array output" somewhere when you actually are).