Code structure fails for editable grid with append

Hi! I´m trying to create an editable grid in which the user can introduce new rows, so that:

1) The data introduced in the editable grid is saved into a record. Also, I´m saving variables from a previous interface (IDFactura, IDPedido, Proveedor), and I want them to be saved in the same record

2) When a new row is added, it is also saved into the record

The problem I´m facing is how to save both type of variables in my record (previous variables and actual ones):

          - For the actual ones (editable grid) I´m using the WriteRecords function inside the interface 

          - For the new ones, I´m adding an a!save function

When I add the a!save function, my actual variables (editable grid) are not saving correctly. In the process model, I´m using a write records smart service too, and it seems that the only variables catched are the previous ones (IdFactura, IdPedido, Proveedor). It´s like the WriteRecords function inside the interface does not work properly if I add the Write Records Smart service in the process model

I would ask for advice and best practises in order to save both type of values (the previous ones passed and the actual ones in the editable grid)

I tried to make changes in the code, adding ri!recordLineasFact into a new a!save parameter (inside the SaveInto of each column), but if I do this the append function does not work correctly.

 - In this case, I added one row to the editable grid (two rows). It generates two almost empty rows and the third one (duplicate of the last row) with all the information. I will post the code in the end

I´m letting the code here

Thanks a lot

CODE 1: the only variables saved are the ones I put with the a!save in the button configuration. The WriteRecords function in the interface does not work

a!localVariables(
  local!data,
  {
    a!sectionLayout(
      label: "Section",
      contents: {
        a!columnsLayout(
          columns: {
            a!columnLayout(
              contents: {
                a!textField(
                  label: "Id Factura",
                  labelPosition: "ABOVE",
                  value: ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{6f993c32-7f64-424a-859f-d779194c4a18}id_factura'],
                  saveInto: ri!recordLineasFact['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{9c440183-9c71-423b-a300-eb4c3ea747fb}idFactura'],
                  refreshAfter: "UNFOCUS",
                  validations: {}
                )
              }
            ),
            a!columnLayout(
              contents: {
                a!textField(
                  label: "Id Pedido",
                  labelPosition: "ABOVE",
                  value: ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{e8009662-ca1c-43da-9c72-2840463214be}id_pedido'],
                  saveInto: ri!recordLineasFact['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{60774c8e-9b47-486f-9fea-b32c525c05fd}idPedido'],
                  refreshAfter: "UNFOCUS",
                  validations: {}
                )
              }
            ),
            a!columnLayout(
              contents: {
                a!textField(
                  label: "Proveedor",
                  labelPosition: "ABOVE",
                  value: ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{c2a60669-567e-41b8-acdd-29729912b3e5}nomProveedor'],
                  saveInto: ri!recordLineasFact['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{844be35b-6de5-434e-9c69-e7c7b8a148dd}proveedor'],
                  refreshAfter: "UNFOCUS",
                  validations: {}
                )
              }
            )
          }
        )
      }
    ),
    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: "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:"ICON")


      },
      rows: a!forEach(
        items: local!data,
        expression: a!gridRowLayout(
          contents: {

            a!textField(value:fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{019eb28b-727b-4e2c-8160-1bcf8a747ef1}material'], saveInto: {fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{019eb28b-727b-4e2c-8160-1bcf8a747ef1}material']}
            ),
            a!floatingPointField( value: fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{eda9bda7-ae57-44e7-a651-d097c8581021}precioUnit'],
            saveInto: {fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{eda9bda7-ae57-44e7-a651-d097c8581021}precioUnit'], a!save(fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{53f231a2-9bf7-40a1-af07-74373fa7bd9f}importe'],if(
              or(isnull(fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{b1b5fc0b-5be4-45be-8342-381cdc56017d}cantidad']), isnull(fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{eda9bda7-ae57-44e7-a651-d097c8581021}precioUnit'])),
              0,
              fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{b1b5fc0b-5be4-45be-8342-381cdc56017d}cantidad'] * fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{eda9bda7-ae57-44e7-a651-d097c8581021}precioUnit']
            ) )},
            required: true,
            validations: {if(a!isNotNullOrEmpty(fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{eda9bda7-ae57-44e7-a651-d097c8581021}precioUnit'])=false,"", if(
              fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{eda9bda7-ae57-44e7-a651-d097c8581021}precioUnit'] < 0,
              "El precio unitario debe ser superior a cero",
              ""
            ))}),
            a!integerField( value: fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{b1b5fc0b-5be4-45be-8342-381cdc56017d}cantidad'],
            saveInto:{fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{b1b5fc0b-5be4-45be-8342-381cdc56017d}cantidad'], a!save(fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{53f231a2-9bf7-40a1-af07-74373fa7bd9f}importe'],if(
              or(isnull(fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{b1b5fc0b-5be4-45be-8342-381cdc56017d}cantidad']), isnull(fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{eda9bda7-ae57-44e7-a651-d097c8581021}precioUnit'])),
              0,
              fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{b1b5fc0b-5be4-45be-8342-381cdc56017d}cantidad'] * fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{eda9bda7-ae57-44e7-a651-d097c8581021}precioUnit']
            ) )},
            required: true,
            validations: {if(a!isNotNullOrEmpty(fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{b1b5fc0b-5be4-45be-8342-381cdc56017d}cantidad'])=false,"", if(
              fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{b1b5fc0b-5be4-45be-8342-381cdc56017d}cantidad'] < 1,
              "La cantidad debe ser superior a cero",
              ""
            ))}),
            a!floatingPointField(
              value: if(
                or(isnull(fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{b1b5fc0b-5be4-45be-8342-381cdc56017d}cantidad']), isnull(fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{eda9bda7-ae57-44e7-a651-d097c8581021}precioUnit'])),
                0,
                fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{b1b5fc0b-5be4-45be-8342-381cdc56017d}cantidad'] * fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{eda9bda7-ae57-44e7-a651-d097c8581021}precioUnit']
              ),
              saveInto: {fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{53f231a2-9bf7-40a1-af07-74373fa7bd9f}importe']},
              required: true,
              validations: {if(a!isNotNullOrEmpty(fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{53f231a2-9bf7-40a1-af07-74373fa7bd9f}importe'])=false,"", if(
                fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{53f231a2-9bf7-40a1-af07-74373fa7bd9f}importe'] < 0,
                "El importe debe ser superior a cero",
                ""
              ))},
              align: "RIGHT"
            ),
            a!richTextDisplayField(
              value: {
                a!richTextIcon(
                  icon: "times-circle",
                  link: a!dynamicLink(
                    value: remove(local!data, fv!index),
                    saveInto: local!data
                  ),
                  linkstyle: "STANDALONE",
                  color: "NEGATIVE"
                )

              }
            )

          }
        )
      ),
      addrowlink: a!dynamicLink(
        label: "Añadir nueva Línea de Factura",
        value: append(
          local!data,                             
          'recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura'()
        ),
        saveInto: local!data
      )
    )
    ,
    a!buttonLayout(
      primaryButtons: {
        a!buttonWidget(
          label: "Completar Creación Factura",
          saveInto: a!writeRecords(
            records:local!data,
            onSuccess: {a!save(local!data, fv!recordsUpdated),                                                   
            a!save(ri!recordLineasFact['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{9c440183-9c71-423b-a300-eb4c3ea747fb}idFactura'], ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{6f993c32-7f64-424a-859f-d779194c4a18}id_factura']),
            a!save(ri!recordLineasFact['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{60774c8e-9b47-486f-9fea-b32c525c05fd}idPedido'], ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{e8009662-ca1c-43da-9c72-2840463214be}id_pedido']),
            a!save(ri!recordLineasFact['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{844be35b-6de5-434e-9c69-e7c7b8a148dd}proveedor'], ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{c2a60669-567e-41b8-acdd-29729912b3e5}nomProveedor'])
          
            }
          ),
          submit: true,
          style: "PRIMARY",
          validate:true
        )
      },
      secondaryButtons: {
        a!buttonWidget(
          label: "Cancelar",
          value: true,
          saveInto: ri!cancel2,
          submit: true,
          style: "NORMAL",
          validate: false
        )
      }
    )

  }
)

CODE 2: tried to make changes and include a!save parameters inside the SaveInto of each column. But in this case, if I have 2 rows, it generates 3 rows (first and second almost empty, and only the third one with all the info)

a!localVariables(
  local!data,
  {
    a!sectionLayout(
      label: "Section",
      contents: {
        a!columnsLayout(
          columns: {
            a!columnLayout(
              contents: {
                a!textField(
                  label: "Id Factura",
                  labelPosition: "ABOVE",
                  value: ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{6f993c32-7f64-424a-859f-d779194c4a18}id_factura'],
                  saveInto: ri!recordLineasFact['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{9c440183-9c71-423b-a300-eb4c3ea747fb}idFactura'],
                  refreshAfter: "UNFOCUS",
                  validations: {}
                )
              }
            ),
            a!columnLayout(
              contents: {
                a!textField(
                  label: "Id Pedido",
                  labelPosition: "ABOVE",
                  value: ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{e8009662-ca1c-43da-9c72-2840463214be}id_pedido'],
                  saveInto: ri!recordLineasFact['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{60774c8e-9b47-486f-9fea-b32c525c05fd}idPedido'],
                  refreshAfter: "UNFOCUS",
                  validations: {}
                )
              }
            ),
            a!columnLayout(
              contents: {
                a!textField(
                  label: "Proveedor",
                  labelPosition: "ABOVE",
                  value: ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{c2a60669-567e-41b8-acdd-29729912b3e5}nomProveedor'],
                  saveInto: ri!recordLineasFact['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{844be35b-6de5-434e-9c69-e7c7b8a148dd}proveedor'],
                  refreshAfter: "UNFOCUS",
                  validations: {}
                )
              }
            )
          }
        )
      }
    ),
    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: "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:"ICON")


      },
      rows: a!forEach(
        items: local!data,
        expression: a!gridRowLayout(
          contents: {

            a!textField(value:fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{019eb28b-727b-4e2c-8160-1bcf8a747ef1}material'], saveInto: {fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{019eb28b-727b-4e2c-8160-1bcf8a747ef1}material'],a!save(ri!recordLineasFact['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{019eb28b-727b-4e2c-8160-1bcf8a747ef1}material'], fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{019eb28b-727b-4e2c-8160-1bcf8a747ef1}material'])}
            ),
            a!floatingPointField( value: fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{eda9bda7-ae57-44e7-a651-d097c8581021}precioUnit'],
            saveInto: {fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{eda9bda7-ae57-44e7-a651-d097c8581021}precioUnit'], a!save(ri!recordLineasFact['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{eda9bda7-ae57-44e7-a651-d097c8581021}precioUnit'], fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{eda9bda7-ae57-44e7-a651-d097c8581021}precioUnit']), a!save(ri!recordLineasFact['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{53f231a2-9bf7-40a1-af07-74373fa7bd9f}importe'],if(
              or(isnull(fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{b1b5fc0b-5be4-45be-8342-381cdc56017d}cantidad']), isnull(fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{eda9bda7-ae57-44e7-a651-d097c8581021}precioUnit'])),
              0,
              fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{b1b5fc0b-5be4-45be-8342-381cdc56017d}cantidad'] * fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{eda9bda7-ae57-44e7-a651-d097c8581021}precioUnit']
            ) )},
            required: true,
            validations: {if(a!isNotNullOrEmpty(fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{eda9bda7-ae57-44e7-a651-d097c8581021}precioUnit'])=false,"", if(
              fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{eda9bda7-ae57-44e7-a651-d097c8581021}precioUnit'] < 0,
              "El precio unitario debe ser superior a cero",
              ""
            ))}),
            a!integerField( value: fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{b1b5fc0b-5be4-45be-8342-381cdc56017d}cantidad'],
            saveInto:{fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{b1b5fc0b-5be4-45be-8342-381cdc56017d}cantidad'],a!save(ri!recordLineasFact['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{b1b5fc0b-5be4-45be-8342-381cdc56017d}cantidad'], fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{b1b5fc0b-5be4-45be-8342-381cdc56017d}cantidad']), a!save(ri!recordLineasFact['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{53f231a2-9bf7-40a1-af07-74373fa7bd9f}importe'],if(
              or(isnull(fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{b1b5fc0b-5be4-45be-8342-381cdc56017d}cantidad']), isnull(fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{eda9bda7-ae57-44e7-a651-d097c8581021}precioUnit'])),
              0,
              fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{b1b5fc0b-5be4-45be-8342-381cdc56017d}cantidad'] * fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{eda9bda7-ae57-44e7-a651-d097c8581021}precioUnit']
            ) )},
            required: true,
            validations: {if(a!isNotNullOrEmpty(fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{b1b5fc0b-5be4-45be-8342-381cdc56017d}cantidad'])=false,"", if(
              fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{b1b5fc0b-5be4-45be-8342-381cdc56017d}cantidad'] < 1,
              "La cantidad debe ser superior a cero",
              ""
            ))}),
            a!floatingPointField(
              value: if(
                or(isnull(fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{b1b5fc0b-5be4-45be-8342-381cdc56017d}cantidad']), isnull(fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{eda9bda7-ae57-44e7-a651-d097c8581021}precioUnit'])),
                0,
                fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{b1b5fc0b-5be4-45be-8342-381cdc56017d}cantidad'] * fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{eda9bda7-ae57-44e7-a651-d097c8581021}precioUnit']
              ),
              saveInto: {fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{53f231a2-9bf7-40a1-af07-74373fa7bd9f}importe'], a!save(ri!recordLineasFact['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{53f231a2-9bf7-40a1-af07-74373fa7bd9f}importe'], fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{53f231a2-9bf7-40a1-af07-74373fa7bd9f}importe'])},
              required: true,
              validations: {if(a!isNotNullOrEmpty(fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{53f231a2-9bf7-40a1-af07-74373fa7bd9f}importe'])=false,"", if(
                fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{53f231a2-9bf7-40a1-af07-74373fa7bd9f}importe'] < 0,
                "El importe debe ser superior a cero",
                ""
              ))},
              align: "RIGHT"
            ),
            a!richTextDisplayField(
              value: {
                a!richTextIcon(
                  icon: "times-circle",
                  link: a!dynamicLink(
                    value: remove(local!data, fv!index),
                    saveInto: local!data
                  ),
                  linkstyle: "STANDALONE",
                  color: "NEGATIVE"
                )

              }
            )

          }
        )
      ),
      addrowlink: a!dynamicLink(
        label: "Añadir nueva Línea de Factura",
        value: append(
          local!data,                             
          'recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura'()
        ),
        saveInto: local!data
      )
    )
    ,
    a!buttonLayout(
      primaryButtons: {
        a!buttonWidget(
          label: "Completar Creación Factura",
          saveInto: a!writeRecords(
            records:local!data,
            onSuccess: {a!save(local!data, fv!recordsUpdated),                                                   
            a!save(ri!recordLineasFact['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{9c440183-9c71-423b-a300-eb4c3ea747fb}idFactura'], ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{6f993c32-7f64-424a-859f-d779194c4a18}id_factura']),
            a!save(ri!recordLineasFact['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{60774c8e-9b47-486f-9fea-b32c525c05fd}idPedido'], ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{e8009662-ca1c-43da-9c72-2840463214be}id_pedido']),
            a!save(ri!recordLineasFact['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{844be35b-6de5-434e-9c69-e7c7b8a148dd}proveedor'], ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{c2a60669-567e-41b8-acdd-29729912b3e5}nomProveedor'])
          
            }
          ),
          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