How to add values in each row

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

Parents
  • 0
    Certified Lead Developer

    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



  • 0
    Certified Lead Developer
    in reply to ZAINAB

    In this code above, the contains() code logic will never be true given the local initial email address list is a text and not an array. Your code is comparing list of emails in simulated api feedback variable with the text

    "test@test.com, test2@test.com, testInvalid@test.com, test3@test.com" and it will always be false. Understand that your foreach will run just once because it has just one item. You need to convert the emails from db into an array then check.

     Try changing the code as below and let me know if its working - 

    a!foreach(
    trim(split(local!initialEmailAddressList,",")),
    if(contains(local!simulatedAPIFeedback.email,fv!item),
    {},
    fv!item)

  • still I'm getting integration 400 error because of unformatted emails are  passed


    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: concat( "{""", joinarray(local!individualEmails, ","), """}" ),*/
    
      local!formattedEmailString: (
    
        joinarray(local!individualEmails, ",")
        /*joinarray(split(local!individualEmails, ";"),",")*/
        /*concat( "{""", 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!GASR_Requests.emailAddresses, local!data.emailAddresses),
                a!startProcess(
                  processmodel:cons!GASR_WRITE_REQUESTS,
                  processParameters: {
                    Emails:local!formattedEmailString,
                  },
    
                ),
                a!save(ri!FormattedEmails,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 please help

  • 0
    Certified Lead Developer
    in reply to ZAINAB

    Can you try this if this gives the output you expect 

    a!localVariables(
      local!emailsfromDb:{
        "test1@test.com, test2@test.com, testInvalid@test.com,test3@test.com"
      },
      local!emailsFromIntegration:{
        a!map(
          email:"test1@test.com",
          uuid:"asdf1233"
        ),
        a!map(
          email:"test2@test.com",
          uuid:"qwer123"
        ),
        a!map(
          email:"test3@test.com",
          uuid:"asdf1233"
        )
      },
      local!emaildbFormatted:trim(split(local!emailsfromDb,",")),
      difference(local!emaildbFormatted,local!emailsFromIntegration.email)
    )

  • Should I modify it in the interface for the formattedemails variable as mentioned in the rule (differen...) ? or in the scriptask


    a!forEach(
    trim(split(pv!EmailPV,",")),
    if(contains(pv!JsonPv.emailAddress,fv!item),
    {},
    fv!item
    )
    )
    

  • 0
    Certified Lead Developer
    in reply to ZAINAB

    I prefer to do in process script task and save in a dedicated variable, but in your case adding in interface shouldn't cause any issues too. So its up to you! If you setup in process then you can see the value in monitoring mode in case any error comes up in integration - it helps in debugging. Hope this clarifies!

Reply Children
  • Hi  


    When I enter emailaddress per line it will be in per line as soon I hit submit button it is showing comma separated .

    My requirement is we have to emailaddresses per line and if any errors from integration then show it in error box in each line .

    Can you please help with this .


     

    But for integration requestbody must be like "testing@test.com,testing2@test.com"



    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!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
            )
          }
        )  )
    )

  • 0
    Certified Lead Developer
    in reply to ZAINAB

    Is your earlier issue resolved with respect to valid emails returned as invalid due to formatting issues? or is this related to the same?

  • it is related to the same ..since the emails are not getting sent in expected order it is the validation is not happening as API is returning (400 bad data)

  • 0
    Certified Lead Developer
    in reply to ZAINAB

    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





  • 0
    Certified Lead Developer
    in reply to ZAINAB

    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?

  • It is taking the value as null for formattedEmailString and API is returning error as 

    "'Emails' must not be empty."












    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
            )
          }
        )  )
    )

  • 0
    Certified Lead Developer
    in reply to ZAINAB

    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