How to copy values of a filled editable grid into another grid in an interface

Hi! I have an editable grid which is filled by the user (possible to add new rows), like in this example:

The editable grid values are saved in a Record, and they all have a common field for each grid created (for example, Employee Set 1, even though it is not shown in the example it should be another column)

Now, I would like to "copy" the created matrix into a grid in another interface, being able to create new columns but  without the possibility of adding extra-rows (I mean, without the "Add Employee" dynamic link)

To be clear, my idea is to re-use the data in another grid, and add a column to identify the data for a new purpose

Thanks a lot!

  Discussion posts and replies are publicly visible

Parents Reply Children
  • Sure, I was thinking about querying the data to make the grid. I know I can do this directly with a read-only grid (from a Record Type), but in this case I would prefer to use an editable grid (to be able to add new columns)

    So I have the following questions:

    1. ¿Do you recommend me to query the database for each column of the grid? ¿Or is there a way to query all the record list (like in the read-only grids) and being able to add new columns?

    2. After executing the query and having the editable grid with the values, ¿could it be possible for the user to change the value manually and apply validations rules over the first value? 

    f.e. I my value for first row and first column is "20". ¿Can I change it to "10" manually and put a validation rule so that I can only change with values <= 20?

  • 0
    Certified Lead Developer
    in reply to carlosp5114

    The documentation has some good examples on editable grids.

    https://docs.appian.com/suite/help/23.3/Editable_Grid_Component.html#editable-grid-with-two-rows-using-looping

    Once you understand how it works, adjust it to work with a static list of your record items. Then use a!queryRecordType to load dynamic data into that local variable.

    docs.appian.com/.../reference-records.html

  • Thanks Stefan! I have been working in my first editable grid, I read again the documentation and examples and understood how it works.

    I have already seen the second link (record type constructors). But here I don´t really understand the difference between using a query or using the record type constructor. Can I use the record type constructor inside the query? Or are they different concepts?

  • 0
    Certified Lead Developer
    in reply to carlosp5114

    Quote from docs: "You can use a record type constructor to create a single record in your expression. The record type constructor allows you to map each value to a particular field reference or relationship reference in the record type."

    This does not query any data from the database. But allows you to toy around with the grid and make it work.

    To accomplish your real use case, you use a!queryRecordType to fetch data from the DB.

  • I understand the fact that I have to query my database in order to obtain my local variable (array from the editable grid)

    I still can´t view in a clear way how to toy with the record type constructor in the editable grid, and where should I use it in the editable grid structure

    I have seen another post in the appian community forum, and they propose this way for each column of the editable grid having the local variable (array)

    The link is:

    https://community.appian.com/discussions/f/rules/18985/indexing-array-in-the-grid

    What do you think? Thanks a lot again

  • I have seen another post in the appian community forum, and they propose this way for each column of the editable grid having the local variable (array)

    Given that it's my comment you screenshotted here - I feel the need to point out that the post in question is not about editable grids at all, but is in fact about the old-style Paging Grid (currently called Read-Only Grid, but still referenced via a!gridField()).  The construct for the different types of grids is completely dissimilar.

    I still can´t view in a clear way how to toy with the record type constructor in the editable grid, and where should I use it in the editable grid structure

    I'm assuming this just means that you'd use the Record Type Constructor to manually set up a local variable to contain a few rows of record type data (aka "fake data" but in a real structure), and/or use the constructor in the "add row" link (if you're using it) to force certain default values into the new row you're adding.

  • Thanks for your answer Mike! First of all, you are absolutely right, the post was about the structure of a Read-Only Grid with the a!GridField function, but I thought maybe I could catch some similarities for my purpose. It´s my mistake.

    On the other hand, wouldn´t be enough to use the a!query function to set up my local variable (array)? Like in this example:

    In this case, I don´t want the user to add new rows or delete them, just to set up the values of the initial array in my editable grid. Where should I include the record type constructor? Is it really necesary to set up the local variable? Any explanation would be helpful

    Thanks again for your response

  • 0
    Certified Lead Developer
    in reply to carlosp5114

    We are talking three different things here. You need to isolate and understand each of them before finally solving that larger challenge.

    Record Type constructor: As Mike pointed out, this is just to create some fake data. Again, split a problem into smaller pieces and solve each piece.

    Editable grid: If you remove/hide the addRowLink, no user can add any new item.

    Query: Once all of the above works, add the last piece to the puzzle and replace the fake data with real data. And yes, that requires a local.

    Some tips on problem solving: www.freecodecamp.org/.../how-to-think-like-a-programmer-lessons-in-problem-solving-d1d8bf1de7d2

  • Alright, step by step:

    1) Record Type Constructor: I still don´t know why I should create fake data by this way. Until now, for my editable grids filled by hand for the user, I directly created my local variable (empty) and then replaced it with the data introduced by the user

    2) Editable grid: I removed the addrowlink correctly

    Now, I´m still not sure how to manage to "replace the fake data with real data"

    1. Grid I want to "copy" / "query"

    2. Editable grid I want to replace with data of the last grid

    My first trial of new code (not working)

    Any help with the code would be useful! Thanks again

    a!localVariables(
      local!grid,
      {
        a!sectionLayout(
          label: "Líneas Factura",
          labelIcon: "list-alt-solid",
          contents: {
            a!gridLayout(
              label: "A continuación, incorpore las líneas de factura correspondientes y pulse el botón de creación",
              headerCells: {
                a!gridLayoutHeaderCell(label: "Linea Pedido"),
                a!gridLayoutHeaderCell(label: "Pedido"),
                a!gridLayoutHeaderCell(label: "Proveedor"),
                a!gridLayoutHeaderCell(label: "Material"),
                a!gridLayoutHeaderCell(label: "Precio Unitario"),
                a!gridLayoutHeaderCell(label: "Cantidad"),
                a!gridLayoutHeaderCell(label: "Importe Total"),
                a!gridLayoutHeaderCell()
              },
              columnConfigs: {
                a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
                a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
                a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
                a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
                a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
                a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
                a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
                a!gridLayoutColumnConfig(width: "ICON")
              },
              rows: a!forEach(
                items: ri!recordLineasPedido,
                expression: a!gridRowLayout(
                  contents: {
                    a!textField(
                      value: fv!index,
                      saveInto: fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{181742a7-4305-4134-b05e-4eebc9c56292}idLineaFactura']
                    ),
                    a!textField(
                      value: fv!index,
                      saveInto: fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{60774c8e-9b47-486f-9fea-b32c525c05fd}idPedido']
                    ),
                    a!textField(
                      value: fv!index,
                      saveInto: fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{844be35b-6de5-434e-9c69-e7c7b8a148dd}proveedor']
                    ),
                    a!textField(
                      value: fv!index,
                      saveInto: fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{019eb28b-727b-4e2c-8160-1bcf8a747ef1}material']
                    ),
                    a!integerField(
                      value: fv!index,
                      saveInto: fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{eda9bda7-ae57-44e7-a651-d097c8581021}precioUnit']
                    ),
                    a!floatingPointField(
                      value: fv!index,
                      saveInto: fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{53f231a2-9bf7-40a1-af07-74373fa7bd9f}importe']
                    )
                  }
                )
              )
            )
          }
        ),
        a!buttonLayout(
          primaryButtons: {
            a!buttonWidget(
              label: "Completar Creación Factura",
              saveInto: a!save(ri!recordLineasFact, local!grid),
              submit: true,
              style: "PRIMARY",
              validate: true
            )
          },
          secondaryButtons: {
            a!buttonWidget(
              label: "Cancelar",
              value: true,
              saveInto: ri!cancel2,
              submit: true,
              style: "NORMAL",
              validate: false
            )
          }
        )
      }
    )

  • 0
    Certified Lead Developer
    in reply to carlosp5114

    Well, an empty grid without an option to add any rows is a bit boring and hard to test. That's what the fake data is for.

    Once things work, use a!queryRecordType to load the data into that local, replacing the fake data.

    BTW, I am not sure what exactly you mean with "data from the last grid". My assumption is that you store this data to the database as the user submits that form.