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
What is the reason to to store the email address in new line is db? If db has data as 'test@test.com;test2@test.com' then you can format the data from db like below before sending to integration.
joinarray(split("test@test.com;test2@test.com", ";"),",")
I need to compare the entered emails vs integration API emails so that I need to display the missing mails from integration on the UI as invalid emails.Since in DB it is storing as the below formatted the integration is not returning the invalid emails properly . Please help in resolving the issue
Since the data type of column 'emailAddresses' is text it cannot store the new line characters. Hence by behavior it will append everything together. We can only use functions to manipulate of format the data here. To help resolve this issue I will need few more inputs. So clarify in as much detail as possible to enable me to help and understand better.
In the local!formattedEmailString is the value in this format? abc@test.com,abc@test.com,abc@test.com
In your process model you are passing the emails comma separated, and that is expected. Are you passing the same pv as is into the integration ?
Is the integration in the process model?
Where does the ri!InvalidEmails populate from?
Are you passing comma separated emailAddresses but Integration is returning semi-colon separated list of those same email Addresses or are you getting 400 bad data error everytime?
yes the value local!formattedEmailString abc@test.com,abc@test.com,abc@test.com yes integrations is in PM.In postman if i test with comma separated data it will work (abc@test.com,abc@test.com,abc@test.com )
These are emails were passed to that API
Is this EmailPV a multiple type process variable? Can you try changing it to single and pass the values from local!formattedEmailString to the corresponding rule input and thus pv EmailPV?
yes
It is taking the value as null for formattedEmailString and API is returning error as
I'm trying to save formattedEmailStrings into a!save(ri!FormattedEmails,local!formattedEmailString), .. I need to pass this data to integration but value is getting passed as NULL
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!save(ri!FormattedEmails,local!formattedEmailString), 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 ) } ) ) )
Can you open the expression editor here and verify its not wrapping variable into "". If you see others don't have = signs in the value column except last two. EVen there one is a pv so the last one you should check and map to pv appropriately.
I changed it but still I'm getting value as null
It is updating in the rule input
Can you try to remove the user input task and add it can. Redo the configurations and see if it works! Till this stage the configurations looks right so it is weird for the rule input to not pass the data into pv. So give it a try