Old requirement: User used to enter multiple email addresses separated with a comma and that combined value was sent from Appian to API for sending emails.
Here the highlighted rule input was saved as Text type in Interface.
Now the requirement from API end has been changed and they have updated the Email addresses variable to list of items. In order to handle this I have updated the Rule input to store multiple values
I tried to use a!foreach() in the saveinto parameter of a!textField() but Interface is not recognizing the multiple values as list of items. Can i please get some suggestions on how to handle this?
Discussion posts and replies are publicly visible
Hi poojithak2926
Please refer the code below.
a!localVariables( local!emailAddress, { a!textField( label: "Text", labelPosition: "ABOVE", value: local!emailAddress, saveInto: { local!emailAddress, if( a!isNullOrEmpty(local!emailAddress), {}, a!save( ri!emailAddress, touniformstring(split(local!emailAddress, ",")) ) ) }, refreshAfter: "UNFOCUS", validations: {} ) } )
Display: Array → comma-separated stringSave: Comma-separated string → arrayYour Rule Input stays as Array type, but the interface handles the conversion automatically.Change your text field saveInto to handle the array conversion:
a!textField( label: "Email Addresses", value: joinarray(ri!emailAddresses, ","), saveInto: { a!save( target: ri!emailAddresses, value: if( isnull(save!value), null, split(save!value, ",") ) ) } )
If API has some changes changing your UI design and variable structure is not necessarily needed. You can keep the same UI and singular email rule input as you had earlier. Only change needed is when you are calling the API instead of passing the rule input data as is just split the data e.g. split(ri!emailAddress,",") - this will convert the comma separated text into an array which your API expects..
If UI change is a requirement then the other responses here can be considered.