a!localVariables( local!data:ri!asr_Requests, local!rawEmails: ri!asr_Requests.emailAddresses, local!integrationResult, 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: joinarray(local!individualEmails, ","),*/ local!formattedEmailString: a!toJson( { emails: joinarray(local!individualEmails, ",") } ), local!validationMessage: if( a!isNotNullOrEmpty(local!invalidEmails), "Emails must be valid and each on a new line.", {} ), a!formLayout( 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!asr_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!asr_Requests.startDate, save!value) }, required: true, requiredMessage: "Start Date is Required", validations: rule!asr_startDateValidation(ri!asr_Requests.startDate) ), a!dateField( label: "End Date", labelPosition: "JUSTIFIED", value: ri!asr_Requests.endDate, saveInto: { a!save(local!data.endDate, save!value), a!save(ri!asr_Requests.endDate, save!value) }, required: true, requiredMessage: "End Date is Required", validations: rule!asr_endDateValidation( ri!asr_Requests.startDate, ri!asr_Requests.endDate ) ) } ), a!columnLayout( contents: { a!textField( label: "Requested By:", labelPosition: "JUSTIFIED", value: rule!GBL_displayUserFirstLast(loggedInUser()), saveInto: ri!asr_Requests.requestorName, readOnly: true() ), a!textField( label: "Requestor Email:", labelPosition: "JUSTIFIED", value: loggedInUser(), saveInto: ri!asr_Requests.requestorEmail, readOnly: true(), validations: {} ), a!dateTimeField( label: "Requested On:", labelPosition: "JUSTIFIED", value: now(), saveInto: ri!asr_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!integrationResult, rule!asr_bulkgetemployees({local!formattedEmailString}),*/ /*),*/ a!save(local!data.emailAddresses, save!value), a!save( ri!asr_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. ", {} ) ) }, style: "#134f5c", marginBelow: "STANDARD" ) } ) } ) } ) }, buttons: a!buttonLayout( primaryButtons: { a!buttonWidget_23r3( label: "Submit", style: "PRIMARY", submit: true, validate: true(), saveInto: { a!startProcess( processmodel:cons!asr_WRITE_REQUESTS, processParameters: { Emails:local!formattedEmailString }, /*onSuccess:a!save(local!processId,fv!processInfo.pp.id) */ ), a!save( ri!asr_Requests.requestorName, rule!GBL_displayUserFirstLast(loggedInUser()) ), a!save( ri!asr_Requests.requestorEmail, loggedInUser() ), a!save(ri!asr_Requests.createdOn, now()), a!save( ri!asr_Requests.requestStatus, cons!asr_AUDIT_STATUS_TYPES[1] ), a!save( ri!asr_Requests.requestType, cons!asr_REQUEST_TYPE ), a!save(ri!asr_Requests.isActive, true()) }, loadingIndicator: true() ) }, secondaryButtons: { a!buttonWidget_23r3( label: "Cancel", style: "NORMAL", submit: true, validate: false, value: true, saveInto: ri!cancel ) } ) ) )
This is my interface .Will enter emailaddresses in line by line format and it should validate the emailaddress format .Once it is done when we click on submit it should pass all the FormattedEmailAddresses to the integration .The input of integration should be emailaddresses and the output of the integration is GUIDs which is an array .
Discussion posts and replies are publicly visible
1. You should store each value from the array in one row in database. So have it stored in database as any other one-to-many related data. Once you receive response from the integration map the data received into your record type format and then write to records.
2. If you receive the integration response as Success then only follow step 1 else skip.
3. If you need to show integration error on UI then here is a similar thread which can help find appropriate way to implement. community.appian.com/.../best-practices-for-handling-errors-in-appian-integrations