Problems to Write a Record from a local variable

Hi! I was trying to pass a local variable values (editable grid in which you can add several rows) to a process model, so that I can use the Write Records Smart Service

At first, I did it this way:

But I would like to know how to transfer this and save into my record (probably best way via process model)

The entire code is:

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: "Factura"),
            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: local!grid,
            expression: a!gridRowLayout(
              contents: {
                a!textField(
                  value: fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{9c440183-9c71-423b-a300-eb4c3ea747fb}idFactura'],
                  saveInto: {
                    fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{9c440183-9c71-423b-a300-eb4c3ea747fb}idFactura']
                  }
                ),
                a!textField(
                  value: fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{60774c8e-9b47-486f-9fea-b32c525c05fd}idPedido'],
                  saveInto: {
                    fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{60774c8e-9b47-486f-9fea-b32c525c05fd}idPedido']
                  }
                ),
                a!textField(
                  value: fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{844be35b-6de5-434e-9c69-e7c7b8a148dd}proveedor'],
                  saveInto: {
                    fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{844be35b-6de5-434e-9c69-e7c7b8a148dd}proveedor']
                  }
                ),
                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!grid, fv!index),
                        saveInto: local!grid
                      ),
                      linkstyle: "STANDALONE",
                      color: "NEGATIVE"
                    )
                  }
                )
              }
            )
          ),
          addrowlink: a!dynamicLink(
            label: "Añadir nueva Línea de Factura",
            saveInto: a!save(
              target: local!grid,
              value: append(
                local!grid,
                'recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura'(
                  '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'],
                  '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'],
                  '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']
                )
              )
            )
          )
        )
      }
    ),
    a!buttonLayout(
      primaryButtons: {
        a!buttonWidget(
          label: "Completar Creación Factura",
          saveInto: a!writeRecords(
            records: local!grid,
            onSuccess: { a!save(local!grid, fv!recordsUpdated) }
          ),
          submit: true,
          style: "PRIMARY",
          validate: true
        )
      },
      secondaryButtons: {
        a!buttonWidget(
          label: "Cancelar",
          value: true,
          saveInto: ri!cancel2,
          submit: true,
          style: "NORMAL",
          validate: false
        )
      }
    )
  }
)

I´m asking this because my intention is to transfer this interface inside another one in which I directly use the write records smart service. And I´m not sure how to assure that both values (the local data shown using WriteRecords in the interface and the other interface values directly saved with the smart service)

The following interface (with the editable grid included) would be like this:

I tried to introduce the editable grid (first posted) and a button to configure the Write records but it is not working. I dont know if it is possible to upload simultaneously different records with the same button. The code is posted below:

a!localVariables(
  local!Listado_ids: index(
    a!queryRecordType(
      recordType: 'recordType!{3c95c0e4-e69d-43f6-b485-e72b24252af7}CPF Maestro Pedidos',
  fields: {
  'recordType!{3c95c0e4-e69d-43f6-b485-e72b24252af7}CPF Maestro Pedidos.fields.{7309402c-2312-4a4e-bdaa-5654789bffb2}idPedido'
  },
  pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 100)
  ).data,
  'recordType!{3c95c0e4-e69d-43f6-b485-e72b24252af7}CPF Maestro Pedidos.fields.{7309402c-2312-4a4e-bdaa-5654789bffb2}idPedido',
  {}
  ),
  local!data: rule!CPF_ObtenerNomProveedor(),
  local!grid,
  a!formLayout(
    label: "Crear Nueva Factura ",
    instructions: "",
    contents: {
      a!sectionLayout(
        label: "Información de Cabecera",
        labelIcon: "file-invoice-dollar",
        contents: {
          a!cardLayout(
            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!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{6f993c32-7f64-424a-859f-d779194c4a18}id_factura'],
                        characterLimit: 255,
                        required: true
                      ),
                      a!dropdownField(
                        label: "Id Pedido",
                        labelPosition: "ABOVE",
                        placeholder: "--- Seleccione un Pedido ---",
                        choiceLabels: {local!Listado_ids},
                        choiceValues: {local!Listado_ids},
                        value: ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{e8009662-ca1c-43da-9c72-2840463214be}id_pedido'],
                        saveInto: ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{e8009662-ca1c-43da-9c72-2840463214be}id_pedido'],
                        searchDisplay: "AUTO",
                        required: true,
                        validations: {}
                      ),
                      a!dateField(
                        label: "Fecha Creación",
                        labelPosition: "ABOVE",
                        value: ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{5e2acd8e-62e0-404e-a1ff-7095727de853}fechaEmision'],
                        saveInto: ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{5e2acd8e-62e0-404e-a1ff-7095727de853}fechaEmision'],
                        required: true
                      )
                    }
                  ),
                  a!columnLayout(
                    contents: {
                      a!floatingPointField(
                        label: "Total Factura",
                        labelPosition: "ABOVE",
                        value: ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{e832ec1e-f394-4193-896c-b1e74035964e}totalFact'],
                        saveInto: ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{e832ec1e-f394-4193-896c-b1e74035964e}totalFact'],
                        required: true
                      ),
                      a!textField(
                        label: "Proveedor",
                        labelPosition: "ABOVE",
                        value: if(a!isUserMemberOfGroup(
                          username: loggedInUser(),
                          groups: a!groupsByName("CPF Proveedores") 
)
,
                        property(local!data, 'recordType!{293f4c78-986f-4eb1-b619-277d91c1eb62}CPF Maestro Proveedores.fields.{cafefb20-cbe5-40e2-8d49-828be3b2cc46}nomProv'), ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{c2a60669-567e-41b8-acdd-29729912b3e5}nomProveedor']
                        ),
                        saveInto: ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{c2a60669-567e-41b8-acdd-29729912b3e5}nomProveedor'],
                        refreshAfter: "UNFOCUS",
                        required: false,
                        readOnly: true,
                        validations: {}
                      ),
                      a!integerField(
                        label: "Días hasta Vencimiento",
                        labelPosition: "ABOVE",
                        value: ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{abef6937-5c5f-41fb-9117-6de24251f7f6}diasVto'],
                        saveInto: ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{abef6937-5c5f-41fb-9117-6de24251f7f6}diasVto'],
                        refreshAfter: "UNFOCUS",
                        required: true,
                        validations: {}
                      )
                    }
                  )
                }
              )
            },
            height: "AUTO",
            style: "TRANSPARENT",
            marginBelow: "STANDARD"
          )
        }
      ),
      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: "Factura"),
              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: local!grid,
              expression: a!gridRowLayout(
                contents: {
                  a!textField(value:fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{9c440183-9c71-423b-a300-eb4c3ea747fb}idFactura'], saveInto: {fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{9c440183-9c71-423b-a300-eb4c3ea747fb}idFactura']}
                  ),
                  a!textField(value:fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{60774c8e-9b47-486f-9fea-b32c525c05fd}idPedido'], saveInto: {fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{60774c8e-9b47-486f-9fea-b32c525c05fd}idPedido']}
                  ),
                  a!textField(value:fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{844be35b-6de5-434e-9c69-e7c7b8a148dd}proveedor'], saveInto: {fv!item['recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura.fields.{844be35b-6de5-434e-9c69-e7c7b8a148dd}proveedor']}
                  ),
                  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!grid, fv!index),
                          saveInto: local!grid
                        ),
                        linkstyle: "STANDALONE",
                        color: "NEGATIVE"
                      )

                    }
                  )

                }
              )
            ),
            addrowlink: a!dynamicLink(
              label: "Añadir nueva Línea de Factura",
              saveInto: a!save(
                target: local!grid,
                value: append(
                  local!grid,
                  'recordType!{6e637180-b344-49d2-a1f7-f87eed0041ba}CPF Lineas Factura'(
              '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'],
              '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'],
              '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']
            )
                )
              )
            )
          ),
          a!buttonArrayLayout(
            buttons: {
              a!buttonWidget(
                label: "Guardar Líneas en Base de Datos",
                saveInto: a!writeRecords(
                  records: local!grid,
                  onSuccess: { a!save(local!grid, fv!recordsUpdated) }
                ),
                submit: false,
                style: "PRIMARY",
                validate: false
              )
            },
            align: "START"
          )

        }
      ),
      a!sectionLayout(
        label: "Documentación Adicional",
        labelIcon: "file-pdf-o",
        contents: {
          a!fileUploadField(
            label: "Fichero factura (PDF)",
            labelPosition: "ABOVE",
            target: cons!CPF_Facturas_Cargadas,
            maxSelections: null,
            value: ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{41911fdc-53f7-44b2-beaa-79ef6f5dbb7e}facturaPDF'],
            saveInto: a!save(ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{41911fdc-53f7-44b2-beaa-79ef6f5dbb7e}facturaPDF'], save!value),
            validations: {}
          )
        }
      )
    },
    buttons: a!buttonLayout(
      primaryButtons: {
        a!buttonWidget(
          label: "COMPLETAR CREACIÓN DE FACTURA",
          saveInto: {
            a!save(ri!recordLineasFact, local!grid),
            a!save(ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{247cdc5f-e6a2-4c0f-ade1-39bd7616500f}createdOn'], now() + intervalds(2,0,0)
            ),
            a!save(ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{3b411df3-3673-4fc6-bbcd-ced7fe8fc3d6}createdBy'],loggedInUser()),
            a!save(ri!recordFact['recordType!{51d44df6-c727-4443-8114-aef8a7509b41}CPF Maestro Facturas.fields.{c2a60669-567e-41b8-acdd-29729912b3e5}nomProveedor'], property(local!data, 'recordType!{293f4c78-986f-4eb1-b619-277d91c1eb62}CPF Maestro Proveedores.fields.{cafefb20-cbe5-40e2-8d49-828be3b2cc46}nomProv')) 
          },
          submit: true,
          style: "PRIMARY",
          validate: true
        )
      },
      secondaryButtons: {
        a!buttonWidget(
          label: "Cancelar",
          value: true,
          saveInto: ri!cancel,
          submit: true,
          style: "NORMAL",
          validate: false
        )
      }
    )
  )
)

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Associate Developer

    If I understand the issue correctly, here's what might help:

    1. If you store the information from the grid inside the local variable, you can save the record data from this local variable into a rule input when submitting the form (on the submit button saveInto list). The rule input will allow you to write this information to the record type later on in the process.

    2. If you want to use the a!writeRecords() smart service, there are a few things you have to keep in mind. First, you can only use ONE smart service per interface evaluation. Second, you can only write ONE record type with that smart service. This means that if you have multiple record types that need to be saved, or you have to save this record type.

    3. Looking at the code, I think oyu should also make sure that the local variable retains the data type of your record type. You can check the type of your local variable like this:

    local!testType: typename(typeof(local!grid))

Reply
  • 0
    Certified Associate Developer

    If I understand the issue correctly, here's what might help:

    1. If you store the information from the grid inside the local variable, you can save the record data from this local variable into a rule input when submitting the form (on the submit button saveInto list). The rule input will allow you to write this information to the record type later on in the process.

    2. If you want to use the a!writeRecords() smart service, there are a few things you have to keep in mind. First, you can only use ONE smart service per interface evaluation. Second, you can only write ONE record type with that smart service. This means that if you have multiple record types that need to be saved, or you have to save this record type.

    3. Looking at the code, I think oyu should also make sure that the local variable retains the data type of your record type. You can check the type of your local variable like this:

    local!testType: typename(typeof(local!grid))

Children
No Data