Skip to main content
January 18, 2024
Question

Troubleshooting a Complex Editable Grid

  • January 18, 2024
  • 12 replies
  • 0 views

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
                            )

    12 replies

    konduruc733182
    January 18, 2024

    Hello kevinp617,

    Could you please insert your could in this way that would improve the readability. besides have you taken a look at this? looks like you have a duplicate grid row layout in your foreach and you can use your ri!item type for your save instead of map.

    Add, Edit, and Remove Data in an Inline Editable Grid

    kevinp617Author
    January 18, 2024

    Hello Konduru, fixed just now and also yes I have read that particular set of documentation, but I'm struggling to accurately identify which part is broken. Could it just be that I need to add the index function variable to the "id"?

    mikes0011
    Brainy
    January 18, 2024
    fixed just

    not to be too nitpicky but i would suggest you revise one more time and paste in your original code with indentation in-tact; that's one of the things a Code Box most enhances about readability here.  Also (personal preference) I select "Java" from the syntax highlighting drop-down; in the absence of a "SAIL" or "Appian Expression" option there, it at least adds some visual distinction to pasted Appian code.

    mikes0011
    Brainy
    January 18, 2024

    This will be much more readable if you provide a cleanly pasted code box with indentaion in-tact.

    (edit: sorry, Konduru beat me to it while i was still typing.  leaving my comment here tho lol)

    konduruc733182
    January 18, 2024

    Took some time for me also. Just few seconds of difference. How to do this type of screen capture anyway always wondered.

    mikes0011
    Brainy
    January 18, 2024

    I use a freeware tool called GreenShot.  You can map it to the PrintScreen button (or any other available hotkey) and it gives you a screen-area selection tool, then opens that selection in a mini editor where you get options like arrows, highlight, obfuscation, and borders.

    How to do this type of screen capture anyway always wondered.
    jayaprakashr0001
    Participating Frequently
    January 19, 2024

    Hi  kevinp617,

    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)