Troubleshooting a Complex Editable Grid

Howdy All,

I'm new to Appian and struggling with how to configure the Editable Grid for a form response.

Particularly trying to troubleshoot the "Add New Row" feature within the Editable Grid.

Any advice or guidance on how to adjust this would be appreciated!

/* Editable Grid */
                        a!sectionLayout(
                          label: "",
                          contents: {
                            a!gridLayout(
                              label: "Please Complete below if there is no quote attached.",
                              labelPosition: "ABOVE",
                              headerCells: {
                               /* 1 */ a!gridLayoutHeaderCell(label: "Action"),
                               /* 2 */ a!gridLayoutHeaderCell(label: "Item Number"),
                               /* 3 */ a!gridLayoutHeaderCell(label: "Item Description", align: "LEFT"),
                               /* 4 */ a!gridLayoutHeaderCell(label: "Part Number", align: "LEFT"),
                               /* 5 */ a!gridLayoutHeaderCell(label: "URL Link"),
                               /* 6 */ a!gridLayoutHeaderCell(label: "Lead Time (Days)"),
                               /* 7 */ a!gridLayoutHeaderCell(label: "Qty"),
                               /* 8 */ a!gridLayoutHeaderCell(label: "Cost Per Unit"),
                               /* 9 */ a!gridLayoutHeaderCell(label: "Total Cost"),
                               /*10 */ a!gridLayoutHeaderCell(label: "")
                              },
                              columnConfigs: {
                               /* 1 */ a!gridLayoutColumnConfig(width: "DISTRIBUTE"),            /*        Action       */
                               /* 2 */ a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 2), /*     Item Number     */
                               /* 3 */ a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3), /*   Item Description  */
                               /* 4 */ a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 2), /*     Part Number     */
                               /* 5 */ a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 2), /*       URL Link      */
                               /* 6 */ a!gridLayoutColumnConfig(width: "DISTRIBUTE"),             /*   Lead Time (Days)  */
                               /* 7 */ a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 1),  /*        Qty          */
                               /* 8 */ a!gridLayoutColumnConfig(width: "DISTRIBUTE"),             /*    Cost Per Unit    */
                               /* 9 */ a!gridLayoutColumnConfig(width: "NARROW"),                 /*      Total Cost     */
                               /*10 */ a!gridLayoutColumnConfig(width: "NARROW")                  /* [Delete Row Column] */
                              },
                              rows: {
                                a!forEach(
                                  items: ri!Item,
                                  expression: a!gridRowLayout(
                                    contents: {
                                      a!textField(
                                        placeholder: "",
                                        value: ri!Item.action,
                                        saveInto: ri!Item.action,
                                        required: false,
                                        validationGroup: "main"
                                      ),
                                      a!textField(
                                        placeholder: "",
                                        value: fv!item.itemnumber[fv!index],
                                        saveInto: fv!item.itemnumber[fv!index],
                                        required: false,
                                        validationGroup: "main"
                                      ),
                                      a!textField(
                                        placeholder: "",
                                        value: fv!item.itemdesc[fv!index],
                                        saveInto: fv!item.itemdesc[fv!index],
                                        characterLimit: 100,
                                        required: false,
                                        validationGroup: "main"
                                      ),
                                      a!textField(
                                        placeholder: "",
                                        value: fv!item.partnumber[fv!index],
                                        saveInto: fv!item.partnumber[fv!index],
                                        required: false,
                                        validationGroup: "main"
                                      ),
                                      a!textField(
                                        placeholder: "",
                                        value: fv!item.urllink[fv!index],
                                        saveInto: fv!item.urllink[fv!index],
                                        required: false,
                                        validationGroup: "main"
                                      ),
                                      a!textField(
                                        placeholder: "",
                                        value: fv!item.leadtime[fv!index],
                                        saveInto: fv!item.leadtime[fv!index],
                                        required: false,
                                        validationGroup: "main"
                                      ),
                                      a!textField(
                                        placeholder: "",
                                        value: fv!item.quantity[fv!index],
                                        saveInto: fv!item.quantity[fv!index],
                                        required: false,
                                        validations: {
                                          if(fv!item.quantity[fv!index] < 1, "Quantity must be greater than zero", "")
                                        },
                                        validationGroup: "main",
                                        align: "RIGHT"
                                      ),
                                      a!floatingPointField(
                                        placeholder: "",
                                        value: fv!item.unitPrice[fv!index],
                                        saveInto: fv!item.unitPrice[fv!index],
                                        required: false,
                                        validations: {
                                          if(fv!item.unitPrice[fv!index] < 0, "Price must be greater than zero", "")
                                        },
                                        validationGroup: "main",
                                        align: "RIGHT"
                                      ),
                                      a!textField(
                                        value: a!currency(isoCode: "USD", value: fv!item.totalc[fv!index]),
                                        readOnly: true,
                                        align: "RIGHT"
                                      ),
                                      a!richTextDisplayField(
                                        value: {
                                          a!richTextIcon(
                                            icon: "times",
                                            link: a!dynamicLink(
                                              saveInto: a!save(ri!Item, remove(ri!Item, fv!index))
                                            ),
                                            linkStyle: "STANDALONE",
                                            color: "NEGATIVE"
                                          )
                                        }
                                      )
                                    }
                                  )
                                ),
                                /* Editable Grid */
                                a!gridRowLayout(
                                  contents: {
                                    /* 1 */  a!textField(
                                      label: "Action",
                                      saveInto: ri!Item['recordType!{18032ed7-381c-4379-b76b-3ef592acf874}KXTItem.fields.{48a1083c-302c-4de1-a61d-245483e72a7d}action'],readOnly: true),                                  /*       Action      */
                                    /* 2 */  a!textField(
                                      label: "Item Number",
                                      saveInto: ri!Item['recordType!{18032ed7-381c-4379-b76b-3ef592acf874}KXTItem.fields.{956062b4-7dc1-480c-903d-41f0a0e16f2a}itemnumber'],readOnly: true),                                  /*     Item Number   */
                                    /* 3 */  a!textField(
                                      label: "Item Description",
                                      saveInto: ri!Item['recordType!{18032ed7-381c-4379-b76b-3ef592acf874}KXTItem.fields.{93159d1a-808d-4010-a9de-3ea3e20a2a16}itemdesc'],readOnly: true),                                  /*  Item Description */
                                    /* 5 */  a!textField(readOnly: true),                                  /*     Part Number   */
                                    /* 6 */  a!textField(readOnly: true),                                  /*      URL Link     */
                                    /* 7 */  a!textField(readOnly: true),                                  /*  Lead Time (Days) */
                                    /* 8 */  a!textField(readOnly: true),                                  /*         Qty       */
                                    /* 9  */ a!textField(value: "Total", readOnly: true, align: "RIGHT"),  /*    Total Cost     */
                                    /* 10 */ a!textField(
                                      value: a!currency(isoCode: "USD", value: sum(a!forEach(
                                        items: "",
                                        expression: fv!item.qty * fv!item.unitPrice
                                      )), format: "SYMBOL"),
                                      readOnly: true,
                                      align: "RIGHT"
                                    ),
                                    /* */ a!textField(readOnly: true)
                                  }
                                )
                              },
                              addRowLink: a!dynamicLink(
                                label: "Add New Item",
                                saveInto: {
                                  a!save(ri!Item, append(ri!Item, a!map(action: "",itemnumber: "",itemdesc: "",partnum: " ",urllink: " ", leadtime: "",qty: tointeger(null),unitPrice: todecimal(null), totalc: "")))
                                }
                              ),
                              rowHeader: 1
                            )

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Associate Developer

    Hi  ,

    made some changes in your code . there is no point having [fv!index].

     

    /* Editable Grid */
    a!localVariables(
      local!data:{
        action: "",
        itemnumber: "",
        itemdesc: "",
        partnum: " ",
        urllink: " ",
        leadtime: "",
        qty: tointeger(null),
        unitPrice: todecimal(null),
        totalc: ""
      },
    a!sectionLayout(
      label: "",
      contents: {
        a!gridLayout(
          label: "Please Complete below if there is no quote attached.",
          labelPosition: "ABOVE",
          headerCells: {
            /* 1 */a!gridLayoutHeaderCell(label: "Action"),
            /* 2 */a!gridLayoutHeaderCell(label: "Item Number"),
            /* 3 */a!gridLayoutHeaderCell(label: "Item Description", align: "LEFT"),
            /* 4 */a!gridLayoutHeaderCell(label: "Part Number", align: "LEFT"),
            /* 5 */a!gridLayoutHeaderCell(label: "URL Link"),
            /* 6 */a!gridLayoutHeaderCell(label: "Lead Time (Days)"),
            /* 7 */a!gridLayoutHeaderCell(label: "Qty"),
            /* 8 */a!gridLayoutHeaderCell(label: "Cost Per Unit"),
            /* 9 */a!gridLayoutHeaderCell(label: "Total Cost"),
            /*10 */a!gridLayoutHeaderCell(label: "")
          },
          columnConfigs: {
            /* 1 */a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
            /*        Action       */
            /* 2 */a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 2),
            /*     Item Number     */
            /* 3 */a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
            /*   Item Description  */
            /* 4 */a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 2),
            /*     Part Number     */
            /* 5 */a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 2),
            /*       URL Link      */
            /* 6 */a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
            /*   Lead Time (Days)  */
            /* 7 */a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 1),
            /*        Qty          */
            /* 8 */a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
            /*    Cost Per Unit    */
            /* 9 */a!gridLayoutColumnConfig(width: "NARROW"),
            /*      Total Cost     */
            /*10 */a!gridLayoutColumnConfig(width: "NARROW")/* [Delete Row Column] */
            
          },
          rows: {
            a!forEach(
              items: ri!Item,
              expression: a!gridRowLayout(
                contents: {
                  a!textField(
                    placeholder: "",
                    value: fv!item.action,
                    saveInto: fv!item.action,
                    required: false,
                    validationGroup: "main"
                  ),
                  a!textField(
                    placeholder: "",
                    value: fv!item.itemnumber,
                    saveInto: fv!item.itemnumber,
                    required: false,
                    validationGroup: "main"
                  ),
                  a!textField(
                    placeholder: "",
                    value: fv!item.itemdesc,
                    saveInto: fv!item.itemdesc,
                    characterLimit: 100,
                    required: false,
                    validationGroup: "main"
                  ),
                  a!textField(
                    placeholder: "",
                    value: fv!item.partnumber,
                    saveInto: fv!item.partnumber,
                    required: false,
                    validationGroup: "main"
                  ),
                  a!textField(
                    placeholder: "",
                    value: fv!item.urllink,
                    saveInto: fv!item.urllink,
                    required: false,
                    validationGroup: "main"
                  ),
                  a!textField(
                    placeholder: "",
                    value: fv!item.leadtime,
                    saveInto: fv!item.leadtime,
                    required: false,
                    validationGroup: "main"
                  ),
                  a!textField(
                    placeholder: "",
                    value: fv!item.quantity,
                    saveInto: fv!item.quantity,
                    required: false,
                    validations: {
                      if(
                        tointeger(fv!item.quantity) < 1,
                        "Quantity must be greater than zero",
                        ""
                      )
                    },
                    validationGroup: "main",
                    align: "RIGHT"
                  ),
                  a!floatingPointField(
                    placeholder: "",
                    value: fv!item.unitPrice,
                    saveInto: fv!item.unitPrice,
                    required: false,
                    validations: {
                      if(
                        tointeger(fv!item.unitPrice) <tointeger(0),
                        "Price must be greater than zero",
                        ""
                      )
                    },
                    validationGroup: "main",
                    align: "RIGHT"
                  ),
                  a!textField(
                    value: a!currency(
                      isoCode: "USD",
                      value: fv!item.totalc
                    ),
                    readOnly: true,
                    align: "RIGHT"
                  ),
                  a!richTextDisplayField(
                    value: {
                      a!richTextIcon(
                        icon: "times",
                        link: a!dynamicLink(
                          saveInto: a!save(ri!Item, remove(ri!Item, fv!index))
                        ),
                        linkStyle: "STANDALONE",
                        color: "NEGATIVE"
                      )
                    }
                  )
                }
              )
            ),
            /* Editable Grid */
            a!gridRowLayout(
              contents: {
                /* 1 */a!textField(
                  label: "Action",
                  saveInto: ri!Item['recordType!{18032ed7-381c-4379-b76b-3ef592acf874}.fields.{48a1083c-302c-4de1-a61d-245483e72a7d}'],
                  readOnly: true
                ),
                /*       Action      */
                /* 2 */a!textField(
                  label: "Item Number",
                  saveInto: ri!Item['recordType!{18032ed7-381c-4379-b76b-3ef592acf874}.fields.{956062b4-7dc1-480c-903d-41f0a0e16f2a}'],
                  readOnly: true
                ),
                /*     Item Number   */
                /* 3 */a!textField(
                  label: "Item Description",
                  saveInto: ri!Item['recordType!{18032ed7-381c-4379-b76b-3ef592acf874}.fields.{93159d1a-808d-4010-a9de-3ea3e20a2a16}'],
                  readOnly: true
                ),
                /*  Item Description */
                /* 5 */a!textField(readOnly: true),
                /*     Part Number   */
                /* 6 */a!textField(readOnly: true),
                /*      URL Link     */
                /* 7 */a!textField(readOnly: true),
                /*  Lead Time (Days) */
                /* 8 */a!textField(readOnly: true),
                /*         Qty       */
                /* 9  */a!textField(
                  value: "Total",
                  readOnly: true,
                  align: "RIGHT"
                ),
                /*    Total Cost     */
                /* 10 */a!textField(
                  value: a!currency(
                    isoCode: "USD",
                    value: sum(
                      a!forEach(
                        items: "",
                        expression: fv!item.qty * fv!item.unitPrice
                      )
                    ),
                    format: "SYMBOL"
                  ),
                  readOnly: true,
                  align: "RIGHT"
                ),
                /* */a!textField(readOnly: true)
              }
            )
          },
          addRowLink: a!dynamicLink(
            label: "Add New Item",
            saveInto: {
              a!save(
                ri!Item,
                append(
                  ri!Item,
                  local!data
                )
              )
            }
          ),
          rowHeader: 1
        )
      }
    )
    )

Reply
  • 0
    Certified Associate Developer

    Hi  ,

    made some changes in your code . there is no point having [fv!index].

     

    /* Editable Grid */
    a!localVariables(
      local!data:{
        action: "",
        itemnumber: "",
        itemdesc: "",
        partnum: " ",
        urllink: " ",
        leadtime: "",
        qty: tointeger(null),
        unitPrice: todecimal(null),
        totalc: ""
      },
    a!sectionLayout(
      label: "",
      contents: {
        a!gridLayout(
          label: "Please Complete below if there is no quote attached.",
          labelPosition: "ABOVE",
          headerCells: {
            /* 1 */a!gridLayoutHeaderCell(label: "Action"),
            /* 2 */a!gridLayoutHeaderCell(label: "Item Number"),
            /* 3 */a!gridLayoutHeaderCell(label: "Item Description", align: "LEFT"),
            /* 4 */a!gridLayoutHeaderCell(label: "Part Number", align: "LEFT"),
            /* 5 */a!gridLayoutHeaderCell(label: "URL Link"),
            /* 6 */a!gridLayoutHeaderCell(label: "Lead Time (Days)"),
            /* 7 */a!gridLayoutHeaderCell(label: "Qty"),
            /* 8 */a!gridLayoutHeaderCell(label: "Cost Per Unit"),
            /* 9 */a!gridLayoutHeaderCell(label: "Total Cost"),
            /*10 */a!gridLayoutHeaderCell(label: "")
          },
          columnConfigs: {
            /* 1 */a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
            /*        Action       */
            /* 2 */a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 2),
            /*     Item Number     */
            /* 3 */a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
            /*   Item Description  */
            /* 4 */a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 2),
            /*     Part Number     */
            /* 5 */a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 2),
            /*       URL Link      */
            /* 6 */a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
            /*   Lead Time (Days)  */
            /* 7 */a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 1),
            /*        Qty          */
            /* 8 */a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
            /*    Cost Per Unit    */
            /* 9 */a!gridLayoutColumnConfig(width: "NARROW"),
            /*      Total Cost     */
            /*10 */a!gridLayoutColumnConfig(width: "NARROW")/* [Delete Row Column] */
            
          },
          rows: {
            a!forEach(
              items: ri!Item,
              expression: a!gridRowLayout(
                contents: {
                  a!textField(
                    placeholder: "",
                    value: fv!item.action,
                    saveInto: fv!item.action,
                    required: false,
                    validationGroup: "main"
                  ),
                  a!textField(
                    placeholder: "",
                    value: fv!item.itemnumber,
                    saveInto: fv!item.itemnumber,
                    required: false,
                    validationGroup: "main"
                  ),
                  a!textField(
                    placeholder: "",
                    value: fv!item.itemdesc,
                    saveInto: fv!item.itemdesc,
                    characterLimit: 100,
                    required: false,
                    validationGroup: "main"
                  ),
                  a!textField(
                    placeholder: "",
                    value: fv!item.partnumber,
                    saveInto: fv!item.partnumber,
                    required: false,
                    validationGroup: "main"
                  ),
                  a!textField(
                    placeholder: "",
                    value: fv!item.urllink,
                    saveInto: fv!item.urllink,
                    required: false,
                    validationGroup: "main"
                  ),
                  a!textField(
                    placeholder: "",
                    value: fv!item.leadtime,
                    saveInto: fv!item.leadtime,
                    required: false,
                    validationGroup: "main"
                  ),
                  a!textField(
                    placeholder: "",
                    value: fv!item.quantity,
                    saveInto: fv!item.quantity,
                    required: false,
                    validations: {
                      if(
                        tointeger(fv!item.quantity) < 1,
                        "Quantity must be greater than zero",
                        ""
                      )
                    },
                    validationGroup: "main",
                    align: "RIGHT"
                  ),
                  a!floatingPointField(
                    placeholder: "",
                    value: fv!item.unitPrice,
                    saveInto: fv!item.unitPrice,
                    required: false,
                    validations: {
                      if(
                        tointeger(fv!item.unitPrice) <tointeger(0),
                        "Price must be greater than zero",
                        ""
                      )
                    },
                    validationGroup: "main",
                    align: "RIGHT"
                  ),
                  a!textField(
                    value: a!currency(
                      isoCode: "USD",
                      value: fv!item.totalc
                    ),
                    readOnly: true,
                    align: "RIGHT"
                  ),
                  a!richTextDisplayField(
                    value: {
                      a!richTextIcon(
                        icon: "times",
                        link: a!dynamicLink(
                          saveInto: a!save(ri!Item, remove(ri!Item, fv!index))
                        ),
                        linkStyle: "STANDALONE",
                        color: "NEGATIVE"
                      )
                    }
                  )
                }
              )
            ),
            /* Editable Grid */
            a!gridRowLayout(
              contents: {
                /* 1 */a!textField(
                  label: "Action",
                  saveInto: ri!Item['recordType!{18032ed7-381c-4379-b76b-3ef592acf874}.fields.{48a1083c-302c-4de1-a61d-245483e72a7d}'],
                  readOnly: true
                ),
                /*       Action      */
                /* 2 */a!textField(
                  label: "Item Number",
                  saveInto: ri!Item['recordType!{18032ed7-381c-4379-b76b-3ef592acf874}.fields.{956062b4-7dc1-480c-903d-41f0a0e16f2a}'],
                  readOnly: true
                ),
                /*     Item Number   */
                /* 3 */a!textField(
                  label: "Item Description",
                  saveInto: ri!Item['recordType!{18032ed7-381c-4379-b76b-3ef592acf874}.fields.{93159d1a-808d-4010-a9de-3ea3e20a2a16}'],
                  readOnly: true
                ),
                /*  Item Description */
                /* 5 */a!textField(readOnly: true),
                /*     Part Number   */
                /* 6 */a!textField(readOnly: true),
                /*      URL Link     */
                /* 7 */a!textField(readOnly: true),
                /*  Lead Time (Days) */
                /* 8 */a!textField(readOnly: true),
                /*         Qty       */
                /* 9  */a!textField(
                  value: "Total",
                  readOnly: true,
                  align: "RIGHT"
                ),
                /*    Total Cost     */
                /* 10 */a!textField(
                  value: a!currency(
                    isoCode: "USD",
                    value: sum(
                      a!forEach(
                        items: "",
                        expression: fv!item.qty * fv!item.unitPrice
                      )
                    ),
                    format: "SYMBOL"
                  ),
                  readOnly: true,
                  align: "RIGHT"
                ),
                /* */a!textField(readOnly: true)
              }
            )
          },
          addRowLink: a!dynamicLink(
            label: "Add New Item",
            saveInto: {
              a!save(
                ri!Item,
                append(
                  ri!Item,
                  local!data
                )
              )
            }
          ),
          rowHeader: 1
        )
      }
    )
    )

Children
No Data