Add multiple values to the interface and store them in DB

Certified Associate Developer

Hi Community Team,

I'm facing issue to store multiple values in Database, My task is to accomplish to add multiple comments in a interface section layout. I need to store them by saving them into Cdt. 

User Scenario: For each comment it needs to generate new Primary Key.. Data need to be entered in a new row for each comment.

Comments  
Comment1 Remove Icon
Comment2 Remove Icon
comment 3 Remove Icon
Add Icon to add new comment

  Discussion posts and replies are publicly visible

Parents
  • You only described the scenario, can you explain in detail what is the issue you are facing and what have you tried ?

  • 0
    Certified Associate Developer
    in reply to Sanchit Gupta (Xebia)

    LOL Joy  I'm getting errors while configuring to save the comments in DB. The storing unusual format and I'm getting only One PK for all comments, instead I need to get Multiple PK's for multiple comments. 

    I had given the input as: 

    Hi 

    Good day

  • Would be more helpful if you can copy the code from interface and paste it in a code box Slight smile

  • 0
    Certified Associate Developer
    in reply to Sanchit Gupta (Xebia)

    a!gridLayout(
          label: "Add Comments",
          emptyGridMessage: "No Comments Added",
          headerCells: {
            a!gridLayoutHeaderCell(
              label: "Comments"
            ),
            a!gridLayoutHeaderCell(
              label: ""
            )
          },
          columnConfigs: {
            a!gridLayoutColumnConfig(
              width: "DISTRIBUTE"
            ),
            a!gridLayoutColumnConfig(
              width: "ICON"
            )
          },
          rows: a!forEach(
            items: ri!mention,
            expression: a!gridRowLayout(
              id: fv!index,
              contents: {
                a!textField(
                  label: "No" & fv!index,
                  labelPosition: "ABOVE",
                  value: fv!item.mention,
                  saveInto: fv!item.mention,
                  validations: {},
                  align: "CENTER"
                ),
                a!imageField(
                  label: "delete " & fv!index,
                  images: a!documentImage(
                    document: a!iconIndicator(
                      "REMOVE"
                    ),
                    altText: "Comment " & fv!index,
                    caption: "Comment " & fv!index,
                    link: a!dynamicLink(
                      value: fv!index,
                      saveInto: {
                        a!save(
                          local!arrayVal,
                          remove(
                            local!arrayVal,
                            save!value
                          )
                        )
                      }
                    )
                  ),
                  size: "ICON"
                )
              }
            )
          ),
          addRowlink: a!dynamicLink(
            label: "Add new comment",
            value: {
              comments: "" 
            },
            saveInto: {
              a!save(
                local!arrayVal,
                append(local!arrayVal,
                  save!value
                )
              )
            }
          )
        )

  • Assuming ri!mention is of Comment CDT type. Your code should look like this:

    a!gridLayout(
      label: "Add Comments",
      emptyGridMessage: "No Comments Added",
      headerCells: {
        a!gridLayoutHeaderCell(label: "Comments"),
        a!gridLayoutHeaderCell(label: "")
      },
      columnConfigs: {
        a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
        a!gridLayoutColumnConfig(width: "ICON")
      },
      rows: a!forEach(
        items: ri!mention,
        expression: a!gridRowLayout(
          id: fv!index,
          contents: {
            a!textField(
              label: "No" & fv!index,
              labelPosition: "ABOVE",
              value: fv!item.mention,
              saveInto: fv!item.mention,
              validations: {},
              align: "CENTER"
            ),
            a!imageField(
              label: "delete " & fv!index,
              images: a!documentImage(
                document: a!iconIndicator("REMOVE"),
                altText: "Comment " & fv!index,
                caption: "Comment " & fv!index,
                link: a!dynamicLink(
                  saveInto: a!save(ri!mention, remove(ri!mention, fv!index))
                )
              ),
              size: "ICON"
            )
          }
        )
      ),
      addRowlink: a!dynamicLink(
        label: "Add new comment",
        saveInto: {
          a!save(
            ri!mention,
            append(ri!mention, type!CommentCDT)
          )
        }
      )
    )

Reply
  • Assuming ri!mention is of Comment CDT type. Your code should look like this:

    a!gridLayout(
      label: "Add Comments",
      emptyGridMessage: "No Comments Added",
      headerCells: {
        a!gridLayoutHeaderCell(label: "Comments"),
        a!gridLayoutHeaderCell(label: "")
      },
      columnConfigs: {
        a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
        a!gridLayoutColumnConfig(width: "ICON")
      },
      rows: a!forEach(
        items: ri!mention,
        expression: a!gridRowLayout(
          id: fv!index,
          contents: {
            a!textField(
              label: "No" & fv!index,
              labelPosition: "ABOVE",
              value: fv!item.mention,
              saveInto: fv!item.mention,
              validations: {},
              align: "CENTER"
            ),
            a!imageField(
              label: "delete " & fv!index,
              images: a!documentImage(
                document: a!iconIndicator("REMOVE"),
                altText: "Comment " & fv!index,
                caption: "Comment " & fv!index,
                link: a!dynamicLink(
                  saveInto: a!save(ri!mention, remove(ri!mention, fv!index))
                )
              ),
              size: "ICON"
            )
          }
        )
      ),
      addRowlink: a!dynamicLink(
        label: "Add new comment",
        saveInto: {
          a!save(
            ri!mention,
            append(ri!mention, type!CommentCDT)
          )
        }
      )
    )

Children