a!localVariables( local!data:ri!GASR_Requests, local!rawEmails: ri!GASR_Requests.emailAddresses, local!isintegrationSuccess, 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!formattedEmailString: a!json({joinarray(local!individualEmails, ",")}),*/ local!formattedEmailString: ( joinarray(local!individualEmails, ",") ), local!validationMessage: if( a!isNotNullOrEmpty(local!invalidEmails), "Emails must be valid and each on a new line.", {} ), local!integrationResult:a!refreshVariable( value: if( a!isNullOrEmpty(local!invalidEmails), rule!GASR_bulkgetemployees( emails:local!formattedEmailString, onSuccess:{}, onError:{} ), {}, ), refreshalways: true() ), a!formLayout_25r1( label: "Production Validation Request", contents: { a!sectionLayout( contents: { a!columnsLayout( columns: { a!columnLayout( contents: { a!boxLayout( label: "", labelSize: "SMALL", contents: { a!columnsLayout( columns: { a!columnLayout( contents: { a!textField( label: "Title:", labelPosition: "JUSTIFIED", value: local!data.requestTitle, saveInto: { a!save(local!data.requestTitle, save!value), a!save( ri!GASR_Requests.requestTitle, save!value ) }, refreshAfter: "KEYPRESS", characterLimit: 100, required: true, requiredMessage: "Title is Required" ), a!dateField( label: "Start Date", labelPosition: "JUSTIFIED", value: local!data.startDate, saveInto: { a!save(local!data.startDate, save!value), a!save(ri!GASR_Requests.startDate, save!value) }, required: true, requiredMessage: "Start Date is Required", validations: rule!GASR_startDateValidation(ri!GASR_Requests.startDate) ), a!dateField( label: "End Date", labelPosition: "JUSTIFIED", value: ri!GASR_Requests.endDate, saveInto: { a!save(local!data.endDate, save!value), a!save(ri!GASR_Requests.endDate, save!value) }, required: true, requiredMessage: "End Date is Required", validations: rule!GASR_endDateValidation( ri!GASR_Requests.startDate, ri!GASR_Requests.endDate ) ) } ), a!columnLayout( contents: { a!textField( label: "Requested By:", labelPosition: "JUSTIFIED", value: rule!GBL_displayUserFirstLast(loggedInUser()), saveInto: ri!GASR_Requests.requestorName, readOnly: true() ), a!textField( label: "Requestor Email:", labelPosition: "JUSTIFIED", value: loggedInUser(), saveInto: ri!GASR_Requests.requestorEmail, readOnly: true(), validations: {} ), a!dateTimeField( label: "Requested On:", labelPosition: "JUSTIFIED", value: now(), saveInto: ri!GASR_Requests.createdOn, readOnly: true(), validations: {} ) } ) } ), 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, save!value), a!save( ri!GASR_Requests.emailAddresses, 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!richTextDisplayField(*/ /*labelPosition: "COLLAPSED",*/ /*value: {*/ /*a!richTextIcon(*/ /*icon: "info-circle",*/ /*caption:"",*/ /*color: "#0000ff",*/ /*size: "MEDIUM"*/ /*),*/ a!textField( label: "error", value: ri!InvalidEmail, ) }, align: "CENTER", showWhen: ri!HasError=true(), style: "INFO", marginAbove: "NONE", marginBelow: "LESS", accessibilityText: "Information message" ), }, style: "#134f5c", marginBelow: "STANDARD" ) } ) } ) } ) }, buttons: a!buttonLayout( primaryButtons: { a!buttonWidget_23r3( label: "Submit", style: "PRIMARY", submit: true, validate: true(), saveInto: { a!save(ri!GASR_Requests.emailAddresses,local!individualEmails), a!startProcess( processmodel:cons!GASR_WRITE_REQUESTS, processParameters: { Emails:local!formattedEmailString, }, ), a!save( ri!GASR_Requests.requestorName, rule!GBL_displayUserFirstLast(loggedInUser()) ), a!save( ri!GASR_Requests.requestorEmail, loggedInUser() ), a!save(ri!GASR_Requests.createdOn, now()), a!save( ri!GASR_Requests.requestStatus, cons!GASR_AUDIT_STATUS_TYPES[1] ), a!save( ri!GASR_Requests.requestType, cons!GASR_REQUEST_TYPE ), a!save(ri!GASR_Requests.isActive, true()), /*a!save(ri!GASR_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 ) } ) ) )
I'm currently passing emailaddresses in each line but when i submit it is storing values as test@test.com;test2@test.com but it has tostore in db as in new line and it has to be passed to an integration as {"test@test.com,test2@test.com"} Can someone please help
Discussion posts and replies are publicly visible
Give this a try and let me know if that works...For Database Storage (with newlines):Change line 219 --> a!save(ri!GASR_Requests.emailAddresses, local!data.emailAddresses),For integration:local!formattedEmailString: concat( "{""", joinarray(local!individualEmails, ","), """}" ),
It looks like the code you attached is working fine... What does the integration do? And why do you convert the list of emails from a string to an array, only to convert it back to a string again?
the integration needs to pass array of emails in {"test@test.com,test2@test.com"} otherwise it is throwing 400 error
integration is failing looks like it is not taking the values in correct format
Have you tried with passing hard coded value?
If it worked could you please share here that value.
in line 219 you assign an array to a text field, and Appian by default concatenates the array by placing a semicolon, that's why you get values as test@test.com;test2@test.com in the database. If you change the line 219 as Shubham suggested, it should work correctly for db changes. For integration part your code should work fine, i think, no changes needed.