How to save the values shown in my editable grid

Hello! I´m having some trouble trying to save my values in an editable grid.

The first 6 columns are read-only (data from a local variable, query of a record) and the 7 one is an editable column (user introduces quantity)

My values are not saving correctly into my rule input "RecordLineasRecepcion"

Could you please tell me how can I save the values of each column? I think I cannot use fv!item in the saveInto parameter of the six first columns because the user is not interacting. Should I use an (or some) a!save functions? Can that work with more than one row?

This is an example of what I want to do:

1) Show the value of the selected field of my local variable

2) Save the value to another record

With my code code, no data is saved when I click "Submit"

I leave my code below (I know that if there is no user interaction data will not be saved when using the SaveInto of each field directly, but I´m not sure how to be able to save the values):

a!localVariables(
  /*mirar para incluir columna extra en variable local*/
  local!DatosLineas: a!queryRecordType(
    recordType: 'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido',
    fields: {
      'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{fcfa4b36-4398-4430-8055-ecfa59daf13a}idLineaPedido','recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{71427dbb-12db-4f83-bd99-f625bf9af271}idPedido', 'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{69e9a834-b2fb-4f35-a36d-3c526c97f4ac}Material','recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad', 'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit', 'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{beb59a89-a332-46d3-b718-a8285f58f942}Importe'
    },
    filters: a!queryFilter(
      field: 'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{71427dbb-12db-4f83-bd99-f625bf9af271}idPedido',
      operator: "=",
      value: ri!record['recordType!{3c95c0e4-e69d-43f6-b485-e72b24252af7}CPF Maestro Pedidos.fields.{7309402c-2312-4a4e-bdaa-5654789bffb2}idPedido']
    ),
    pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 100)
  ).data
  ,
  {
    a!sectionLayout(
      label: "Datos Recepción",
      labelIcon: "dolly",
      contents: {
        a!columnsLayout(
          columns: {
            a!columnLayout(
              contents: {
                a!textField(
                  label: "Id Recepción",
                  labelPosition: "ABOVE",
                  value: ri!RecordRecepciones['recordType!{b6fc6108-1f5d-4cbe-9c5c-08da4b1d58f3}CPF Maestro Recepciones.fields.{cb86a21e-a5e5-4ec7-98dc-14e94cc5736c}idRecepcion'],
                  saveInto: ri!RecordRecepciones['recordType!{b6fc6108-1f5d-4cbe-9c5c-08da4b1d58f3}CPF Maestro Recepciones.fields.{cb86a21e-a5e5-4ec7-98dc-14e94cc5736c}idRecepcion'],
                  refreshAfter: "UNFOCUS",
                  validations: {}
                )
              }
            ),
            a!columnLayout(
              contents: {
                a!dateTimeField(
                  label: "Fecha y hora de Recepción",
                  labelPosition: "ABOVE",
                  value: ri!RecordRecepciones['recordType!{b6fc6108-1f5d-4cbe-9c5c-08da4b1d58f3}CPF Maestro Recepciones.fields.{4fa92044-3c8b-438b-b77e-30bf88efbae3}FechaRecepcion'],
                  saveInto: ri!RecordRecepciones['recordType!{b6fc6108-1f5d-4cbe-9c5c-08da4b1d58f3}CPF Maestro Recepciones.fields.{4fa92044-3c8b-438b-b77e-30bf88efbae3}FechaRecepcion'],
                  validations: {}
                )
              }
            )
          }
        )
      }
    ),
    a!sectionLayout(
      label: "Líneas Recepción",
      labelIcon: "list-alt-solid",
      contents: {
        a!gridLayout(
          label: "A continuación, introduzca las cantidades a recepcionar para cada línea de pedido y pulse el botón de Recepción",
          headerCells: {
            a!gridLayoutHeaderCell(label: "Linea Pedido"),
            a!gridLayoutHeaderCell(label: "Pedido"),
            a!gridLayoutHeaderCell(label: "Material"),
            a!gridLayoutHeaderCell(label: "Cantidad"),
            a!gridLayoutHeaderCell(label: "Precio Unitario"),
            a!gridLayoutHeaderCell(label: "Importe Total"),
            a!gridLayoutHeaderCell(label: "Cantidad Recepcionada"),
            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: local!DatosLineas,
            expression: a!gridRowLayout(
              contents: {
                a!textField(
                  value: fv!index,
                  readOnly:true
                ),
                a!textField(
                  value: fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{71427dbb-12db-4f83-bd99-f625bf9af271}idPedido'],
                  saveInto: {
                  },
                  readOnly:true
                ),
              
                a!textField(
                  value: fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{69e9a834-b2fb-4f35-a36d-3c526c97f4ac}Material'],
                  saveInto:{fv!item['recordType!{20fd7d81-a6d6-4fee-9219-afab0a7df2e4}CPF Lineas Recepciones.fields.{5e36f0f0-c022-4883-bc2c-195b92a6b9e0}Material']},
                  readOnly:true
                ),
                a!integerField(
                  value: fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad'],
                  saveInto: {
                  },
                  required: true,
                  readOnly:true,
                  validations: {
                  }
                ),
                a!floatingPointField(
                  value: fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit'],
                  saveInto: {fv!item['recordType!{20fd7d81-a6d6-4fee-9219-afab0a7df2e4}CPF Lineas Recepciones.fields.{9255c197-7e92-4f29-8e6a-104967146dcb}PrecioUnit']},
                  required: true,
                  readOnly:true,
                  validations: {
                  }
                ),
                a!floatingPointField(
                  value: fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{beb59a89-a332-46d3-b718-a8285f58f942}Importe'],
                  saveInto: {fv!item['recordType!{20fd7d81-a6d6-4fee-9219-afab0a7df2e4}CPF Lineas Recepciones.fields.{7c444d45-8e9d-4542-a4a7-e1633eaef735}ImporteLinea']
                  },
                  required: true,
                  readOnly:true,
                  validations: {
                  },
                  align: "RIGHT"
                ),
                a!integerField(
                  value: fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{bd0fe4ca-322c-422e-89e5-97e5194817a1}CantRecepAcum'],
                  saveInto: { fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{bd0fe4ca-322c-422e-89e5-97e5194817a1}CantRecepAcum']
                  }
                  ),

                a!richTextDisplayField(
                  value: {
                    a!richTextIcon(
                      icon: "times-circle",
                      link: a!dynamicLink(
                        value: remove(local!DatosLineas, fv!index),
                        saveInto: local!DatosLineas
                      ),
                      linkstyle: "STANDALONE",
                      color: "NEGATIVE"
                    )
                  }
                )
              }
            )
          )
        )
      }
    ),
    a!buttonLayout(
      primaryButtons: {
        a!buttonWidget(
          label: "Completar Recepción",
          saveInto:{ a!save(
            /*cambiar por recordLineasRecepciones*/
            ri!recordLineasRecep,
            local!DatosLineas
          )
          },
          submit: true,
          style: "PRIMARY",
          validate: true
        )
      },
      secondaryButtons: {
        a!buttonWidget(
          label: "Cancelar",
          value: true,
          saveInto: ri!cancel2,
          submit: true,
          style: "NORMAL",
          validate: false
        )
      }
    )
  }
)

Code without using the saveInto parameters in non-interactive fields (still no values saved)

a!localVariables(
  /*mirar para incluir columna extra en variable local*/
  local!DatosLineas: a!queryRecordType(
    recordType: 'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido',
    fields: {
      'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{fcfa4b36-4398-4430-8055-ecfa59daf13a}idLineaPedido','recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{71427dbb-12db-4f83-bd99-f625bf9af271}idPedido', 'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{69e9a834-b2fb-4f35-a36d-3c526c97f4ac}Material','recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad', 'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit', 'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{beb59a89-a332-46d3-b718-a8285f58f942}Importe'
    },
    filters: a!queryFilter(
      field: 'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{71427dbb-12db-4f83-bd99-f625bf9af271}idPedido',
      operator: "=",
      value: ri!record['recordType!{3c95c0e4-e69d-43f6-b485-e72b24252af7}CPF Maestro Pedidos.fields.{7309402c-2312-4a4e-bdaa-5654789bffb2}idPedido']
    ),
    pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 100)
  ).data
  ,
  {
    a!sectionLayout(
      label: "Datos Recepción",
      labelIcon: "dolly",
      contents: {
        a!columnsLayout(
          columns: {
            a!columnLayout(
              contents: {
                a!textField(
                  label: "Id Recepción",
                  labelPosition: "ABOVE",
                  value: ri!RecordRecepciones['recordType!{b6fc6108-1f5d-4cbe-9c5c-08da4b1d58f3}CPF Maestro Recepciones.fields.{cb86a21e-a5e5-4ec7-98dc-14e94cc5736c}idRecepcion'],
                  saveInto: ri!RecordRecepciones['recordType!{b6fc6108-1f5d-4cbe-9c5c-08da4b1d58f3}CPF Maestro Recepciones.fields.{cb86a21e-a5e5-4ec7-98dc-14e94cc5736c}idRecepcion'],
                  refreshAfter: "UNFOCUS",
                  validations: {}
                )
              }
            ),
            a!columnLayout(
              contents: {
                a!dateTimeField(
                  label: "Fecha y hora de Recepción",
                  labelPosition: "ABOVE",
                  value: ri!RecordRecepciones['recordType!{b6fc6108-1f5d-4cbe-9c5c-08da4b1d58f3}CPF Maestro Recepciones.fields.{4fa92044-3c8b-438b-b77e-30bf88efbae3}FechaRecepcion'],
                  saveInto: ri!RecordRecepciones['recordType!{b6fc6108-1f5d-4cbe-9c5c-08da4b1d58f3}CPF Maestro Recepciones.fields.{4fa92044-3c8b-438b-b77e-30bf88efbae3}FechaRecepcion'],
                  validations: {}
                )
              }
            )
          }
        )
      }
    ),
    a!sectionLayout(
      label: "Líneas Recepción",
      labelIcon: "list-alt-solid",
      contents: {
        a!gridLayout(
          label: "A continuación, introduzca las cantidades a recepcionar para cada línea de pedido y pulse el botón de Recepción",
          headerCells: {
            a!gridLayoutHeaderCell(label: "Linea Pedido"),
            a!gridLayoutHeaderCell(label: "Pedido"),
            a!gridLayoutHeaderCell(label: "Material"),
            a!gridLayoutHeaderCell(label: "Cantidad"),
            a!gridLayoutHeaderCell(label: "Precio Unitario"),
            a!gridLayoutHeaderCell(label: "Importe Total"),
            a!gridLayoutHeaderCell(label: "Cantidad Recepcionada"),
            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: local!DatosLineas,
            expression: a!gridRowLayout(
              contents: {
                a!textField(
                  value: fv!index,
                  readOnly:true
                ),
                a!textField(
                  value: fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{71427dbb-12db-4f83-bd99-f625bf9af271}idPedido'],
                  saveInto: {
                  },
                  readOnly:true
                ),
              
                a!textField(
                  value: fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{69e9a834-b2fb-4f35-a36d-3c526c97f4ac}Material'],
                  saveInto:{},
                  readOnly:true
                ),
                a!integerField(
                  value: fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad'],
                  saveInto: {
                  },
                  required: true,
                  readOnly:true,
                  validations: {
                  }
                ),
                a!floatingPointField(
                  value: fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit'],
                  saveInto: {},
                  required: true,
                  readOnly:true,
                  validations: {
                  }
                ),
                a!floatingPointField(
                  value: fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{beb59a89-a332-46d3-b718-a8285f58f942}Importe'],
                  saveInto: {
                  },
                  required: true,
                  readOnly:true,
                  validations: {
                  },
                  align: "RIGHT"
                ),
                a!integerField(
                  value: fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{bd0fe4ca-322c-422e-89e5-97e5194817a1}CantRecepAcum'],
                  saveInto: { fv!item['recordType!{20fd7d81-a6d6-4fee-9219-afab0a7df2e4}CPF Lineas Recepciones.fields.{5b2d9770-999d-481c-927b-a2d7fc000098}CantidadRecep']
                  }
                  ),

                a!richTextDisplayField(
                  value: {
                    a!richTextIcon(
                      icon: "times-circle",
                      link: a!dynamicLink(
                        value: remove(local!DatosLineas, fv!index),
                        saveInto: local!DatosLineas
                      ),
                      linkstyle: "STANDALONE",
                      color: "NEGATIVE"
                    )
                  }
                )
              }
            )
          )
        )
      }
    ),
    a!buttonLayout(
      primaryButtons: {
        a!buttonWidget(
          label: "Completar Recepción",
          saveInto:{ a!save(
            /*cambiar por recordLineasRecepciones*/
            ri!recordLineasRecep,
            local!DatosLineas
          )
          },
          submit: true,
          style: "PRIMARY",
          validate: true
        )
      },
      secondaryButtons: {
        a!buttonWidget(
          label: "Cancelar",
          value: true,
          saveInto: ri!cancel2,
          submit: true,
          style: "NORMAL",
          validate: false
        )
      }
    )
  }
)

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    without using the saveInto parameters in non-interactive fields

    This literally makes no difference.  All that matters is the saveInto in your "submit" button.

    Can you confirm what data type / configuration you have on "ri!recordLineasRecep"?  If it doesn't match the record type queried into your Local Variable then the save might not work.  Your screenshot does not show enough detail to confirm what type it is or whether it's correctly configured to store an array, both of which are important.

    I just took 5 minutes to type up a simple analogue on my dev environment and it seems to work fine (the following is what it looks like after clicking "test")

  • Hi Mike! Thanks for your answer

    I think the main difference between your code and mine is that your local variable default data results by querying a record type, and then saving values and adding on the same record type  (correct me if I´m wrong)

    In my case, my default data is from a record (CPF_Lineas_Pedido) and I want to save it in another record (CPF_Lineas_Recepciones).

    I have checked my rule input (recordLineasRecep), and logically this record is not matching the queried record (as I told you in my first paragraph). How can I change my approach to save my data in another record fields?

    If I change my rule input to type "text", my values are saved (but in text format, not in record type format):

    If I try to put it in "record" format, then the rule input remains empty ([  ])

    How can I change the format in order to save the values in the record?

    *Additional notes:

    1) It seems like my local variable has "dependance" from the record queried. I think this is causing me trouble when I try to save in a record with a different structure

    2) I tried to pass my data from my local variable to another local variable (default:empty {}), but the structure and "dependance" is the same. Is it possible to make a local variable with the same structure of the new Record in which I want to save the values??? How can I configure it and the save parameter of the button?

    3) I have seen that is possible to point to my local variable values with loca!Data.field (being field the name of my column). But in this case my local variable is not declared manually, its a query. Is there any possibility to set the structure of my local variable when I declare it as a query?

    Thanks a lot

Reply
  • Hi Mike! Thanks for your answer

    I think the main difference between your code and mine is that your local variable default data results by querying a record type, and then saving values and adding on the same record type  (correct me if I´m wrong)

    In my case, my default data is from a record (CPF_Lineas_Pedido) and I want to save it in another record (CPF_Lineas_Recepciones).

    I have checked my rule input (recordLineasRecep), and logically this record is not matching the queried record (as I told you in my first paragraph). How can I change my approach to save my data in another record fields?

    If I change my rule input to type "text", my values are saved (but in text format, not in record type format):

    If I try to put it in "record" format, then the rule input remains empty ([  ])

    How can I change the format in order to save the values in the record?

    *Additional notes:

    1) It seems like my local variable has "dependance" from the record queried. I think this is causing me trouble when I try to save in a record with a different structure

    2) I tried to pass my data from my local variable to another local variable (default:empty {}), but the structure and "dependance" is the same. Is it possible to make a local variable with the same structure of the new Record in which I want to save the values??? How can I configure it and the save parameter of the button?

    3) I have seen that is possible to point to my local variable values with loca!Data.field (being field the name of my column). But in this case my local variable is not declared manually, its a query. Is there any possibility to set the structure of my local variable when I declare it as a query?

    Thanks a lot

Children
  • 0
    Certified Lead Developer
    in reply to carlosp5114
    my default data is from a record (CPF_Lineas_Pedido) and I want to save it in another record (CPF_Lineas_Recepciones)

    Sorry for the late reply - community just decided to ... never notify me at all about your reply (but then again, that seems to be the standard functionality lately).

    I didn't quite realize you're trying to typecast directly between two different record types.  For CDT or Dictionary data, typecasting just works as long as the field names exactly match.  For record type data, I have no idea whether it does or not.  You would likely need to iterate over your original queried record type entries and cast them into an array of the new record type you want to create, but I'm not sure.  As far as I know, this might directly explain why your saveInto isn't working.  If you want to double check, you could (temporarily) change the saveInto to point the save at a Rule Input of a record type (array) matching the type of the queried data, and see if it behaves any differently.