Data needs to be stored in line by line

in a paragraph field i will provide input as 

test1

test2

test3

How this data will be stored in db ,is it will be in line by line as separate string or as a single string

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    If I understood correctly, you want to store these as separate line items in the DB but have them in one paragraph field in the interface?

  • 0
    Certified Senior Developer
    in reply to ZAINAB

    Hello ,

    You can try using the below format. But you will have to construct the data for each line value and map your Parent record/data PK here and also try to have a sort/order value using the indexes, so that the text entered is always displayed in the correct order. 

    a!localVariables(
      local!save,
      local!update:if(
        a!isNullOrEmpty(local!save),
        {},
        reject(
          fn!isnull(_),
          split(local!save,"
    ")
        )
      ),
      {
        a!paragraphField(
          label: "Paragraph",
          labelPosition: "ABOVE",
          value: local!save,
          saveInto: local!save,
          refreshAfter: "UNFOCUS",
          height: "MEDIUM",
          validations: {}
        )
      }
    )

  • 0
    Certified Lead Developer
    in reply to ZAINAB

    Split them using the split function and then run a!forLoop() in it to construct a CDT for every item the split() function returned. 

  • = a!localVariables(
      local!emails: ri!emailAddresses,
      local!invalidEmails: if(
        isnull(local!emails),
        {},
        joinarray(
          reject(
            isnull(_),
            a!forEach(
              items: split(local!emails, " "),
              expression: if(
                regexmatch(
                  pattern: "^[A-Z0-9\'\+\&\%_-]+(\.{0,1}[A-Z0-9\'\+\&\%_-]+)*[@]{1}[A-Z0-9.-]*[A-Z0-9-]+[.]{1}[A-Z]{2,6}$",
                  searchString: fv!item,
                  regexFlags: "si"
                ),
                null,
                fv!index
              )
            )
          ),
          ","
        )
      ),
      local!validation: if(
        isnull(local!invalidEmails),
        {},
        "Invalid email at " & local!invalidEmails & " position(s) "
      ),
             a!paragraphField(
                            label: "Email Addresses",
                            labelPosition: "JUSTIFIED",
                            placeholder: "Email Addresses should be one per line (can be pasted from Excel)",
                            value: ri!emailAddresses,
                            saveInto: ri!emailAddresses,
                            refreshAfter: "UNFOCUS",
                            height: "TALL",
                            required: true,
                            validations: local!validation
                          )
                          )


    Hi   /   ,this is my code where i will be pasting /entering email addresses in line by line  in paragraph field . so i want to have 2 validations where 1st validation checks for line delimiter and 2nd validation for email format .

    How the emailaddresses are saved in dB  is it line by line only ?

    I should pass this email addresses to an api in line by line .can you please suggest how to validate those emails and then pass it to api line by line. 

Reply
  • = a!localVariables(
      local!emails: ri!emailAddresses,
      local!invalidEmails: if(
        isnull(local!emails),
        {},
        joinarray(
          reject(
            isnull(_),
            a!forEach(
              items: split(local!emails, " "),
              expression: if(
                regexmatch(
                  pattern: "^[A-Z0-9\'\+\&\%_-]+(\.{0,1}[A-Z0-9\'\+\&\%_-]+)*[@]{1}[A-Z0-9.-]*[A-Z0-9-]+[.]{1}[A-Z]{2,6}$",
                  searchString: fv!item,
                  regexFlags: "si"
                ),
                null,
                fv!index
              )
            )
          ),
          ","
        )
      ),
      local!validation: if(
        isnull(local!invalidEmails),
        {},
        "Invalid email at " & local!invalidEmails & " position(s) "
      ),
             a!paragraphField(
                            label: "Email Addresses",
                            labelPosition: "JUSTIFIED",
                            placeholder: "Email Addresses should be one per line (can be pasted from Excel)",
                            value: ri!emailAddresses,
                            saveInto: ri!emailAddresses,
                            refreshAfter: "UNFOCUS",
                            height: "TALL",
                            required: true,
                            validations: local!validation
                          )
                          )


    Hi   /   ,this is my code where i will be pasting /entering email addresses in line by line  in paragraph field . so i want to have 2 validations where 1st validation checks for line delimiter and 2nd validation for email format .

    How the emailaddresses are saved in dB  is it line by line only ?

    I should pass this email addresses to an api in line by line .can you please suggest how to validate those emails and then pass it to api line by line. 

Children