How to connect a data store to a record

Hi! I used to work with records, uploading the data based on a manual task in an interface (user introduces parameters and the record updates the info). However, I had to use a data store entity for an editable grid programmation, and I dont know if there is a chance to upload the record based on the data store entity. Thanks!

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Why do you have to use a data store for an editable grid? This is confusing ...

  • When I tried to use records, an error appears (cannot index null values). It´s true that I created my record from scratch and it´s empty, but I don´t think this should be a problem. If it is not an inconvenience, could you tell me what is wrong with my code ? I´m posting images and the real code, ( "PTPP_Invoice_Lines" is my empty record, I want the user to be able to add new rows of information, and update the record) and an image of the error too 

    Next, error that happens when I try to add a new row (using records in the code)

    Then, my code:


    a!formLayout(
    label: "Invoice Detail",
    contents: {
    a!gridLayout(
    label: "Invoice Lines Information",
    labelPosition: "ABOVE",
    headerCells: {
    a!gridLayoutHeaderCell(label: "Purchase Order"),
    a!gridLayoutHeaderCell(label: "Date"),
    a!gridLayoutHeaderCell(label: "Total Value"),
    a!gridLayoutHeaderCell(label: "Material"),
    a!gridLayoutHeaderCell(label: "Supplier"),
    a!gridLayoutHeaderCell(label: "")
    },
    columnConfigs: {
    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!InvoiceLines,
    expression: a!gridRowLayout(
    contents: {
    a!textField(value:ri!InvoiceLines['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{ab97d392-b365-425a-a0e5-116da756c87a}id_orden'], saveInto: ri!InvoiceLines['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{ab97d392-b365-425a-a0e5-116da756c87a}id_orden']),
    a!textField(value:ri!InvoiceLines['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{25003162-d3d0-4466-86f8-471cb1e37589}fecha_orden'], saveInto: ri!InvoiceLines['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{25003162-d3d0-4466-86f8-471cb1e37589}fecha_orden']),
    a!textField(value:ri!InvoiceLines['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{c228ed4c-21cb-4af4-a313-88f26e7874da}total_orden'], saveInto: ri!InvoiceLines['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{c228ed4c-21cb-4af4-a313-88f26e7874da}total_orden']),
    a!textField(value:ri!InvoiceLines['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{5f4060f6-827d-41b5-88e7-0328ec1309bc}Material'], saveInto: ri!InvoiceLines['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{5f4060f6-827d-41b5-88e7-0328ec1309bc}Material']),
    a!textField(value:ri!InvoiceLines['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{d9317466-7426-47af-bd64-22a998c636e6}id_proveedor'], saveInto: ri!InvoiceLines['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{d9317466-7426-47af-bd64-22a998c636e6}id_proveedor']),
    a!richTextDisplayField(
    value: a!richTextIcon(
    icon: "times-circle",
    link: a!dynamicLink(
    saveinto: a!save(
    target: ri!InvoiceLines, value: remove(
    ri!InvoiceLines, fv!index
    )
    )
    ),
    color: "NEGATIVE"
    )
    )
    }
    )
    )

    },
    selectionSaveInto: {},
    addRowLink: a!dynamicLink(
    label: "Add new Invoice Line",
    saveinto: a!save(target: ri!InvoiceLines, append(ri!InvoiceLines['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{ab97d392-b365-425a-a0e5-116da756c87a}id_orden'], ri!InvoiceLines))
    ),
    validations: {},
    shadeAlternateRows: true
    )
    },
    buttons: a!buttonLayout(
    primaryButtons: {
    a!buttonWidget(
    label: "Submit ",
    submit: true,
    style: "PRIMARY",
    validate: true
    )
    },
    secondaryButtons: {
    a!buttonWidget(
    label: "Cancel",
    value: true,
    saveInto: ri!cancel,
    submit: true,
    style: "NORMAL",
    validate: false
    )
    }
    )
    )

  •       a!formLayout(
            label: "Invoice Detail",
            contents: {
              a!gridLayout(
                label: "Invoice Lines Information",
                labelPosition: "ABOVE",
                headerCells: {
                  a!gridLayoutHeaderCell(label: "Purchase Order"),
                  a!gridLayoutHeaderCell(label: "Date"),
                  a!gridLayoutHeaderCell(label: "Total Value"),
                  a!gridLayoutHeaderCell(label: "Material"),
                  a!gridLayoutHeaderCell(label: "Supplier"),
                  a!gridLayoutHeaderCell(label: "")
                },
                columnConfigs: {
                  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!InvoiceLines,
                    expression: a!gridRowLayout(
                      contents: {
                        a!textField(value:ri!InvoiceLines['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{ab97d392-b365-425a-a0e5-116da756c87a}id_orden'], saveInto: ri!InvoiceLines['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{ab97d392-b365-425a-a0e5-116da756c87a}id_orden']),
                        a!textField(value:ri!InvoiceLines['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{25003162-d3d0-4466-86f8-471cb1e37589}fecha_orden'], saveInto: ri!InvoiceLines['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{25003162-d3d0-4466-86f8-471cb1e37589}fecha_orden']),
                        a!textField(value:ri!InvoiceLines['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{c228ed4c-21cb-4af4-a313-88f26e7874da}total_orden'], saveInto: ri!InvoiceLines['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{c228ed4c-21cb-4af4-a313-88f26e7874da}total_orden']),
                        a!textField(value:ri!InvoiceLines['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{5f4060f6-827d-41b5-88e7-0328ec1309bc}Material'], saveInto: ri!InvoiceLines['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{5f4060f6-827d-41b5-88e7-0328ec1309bc}Material']),
                        a!textField(value:ri!InvoiceLines['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{d9317466-7426-47af-bd64-22a998c636e6}id_proveedor'], saveInto: ri!InvoiceLines['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{d9317466-7426-47af-bd64-22a998c636e6}id_proveedor']),
                        a!richTextDisplayField(
                          value: a!richTextIcon(
                            icon: "times-circle",
                            link: a!dynamicLink(
                              saveinto: a!save(
                                target: ri!InvoiceLines, value: remove(
                                  ri!InvoiceLines, fv!index
                                )
                              )
                            ),
                            color: "NEGATIVE"
                          )
                        )
                      }
                    )
                  )
    
                },
                selectionSaveInto: {},
                addRowLink: a!dynamicLink(
                  label: "Add new Invoice Line",
                  saveinto: a!save(target: ri!InvoiceLines, append(ri!InvoiceLines['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{ab97d392-b365-425a-a0e5-116da756c87a}id_orden'], ri!InvoiceLines))
                ),
                validations: {},
                shadeAlternateRows: true
              )
            },
            buttons: a!buttonLayout(
              primaryButtons: {
                a!buttonWidget(
                  label: "Submit ",
                  submit: true,
                  style: "PRIMARY",
                  validate: true
                )
              },
              secondaryButtons: {
                a!buttonWidget(
                  label: "Cancel",
                  value: true,
                  saveInto: ri!cancel,
                  submit: true,
                  style: "NORMAL",
                  validate: false
                )
              }
            )
      )
      

    I include the code with better format. Thanks!

  • 0
    Certified Lead Developer
    in reply to carlosp5114

    This

    a!textField(value:ri!InvoiceLines

    must become

    a!textField(value:fv!item

    That's why you use the foreach.

    www.youtube.com/watch

  • Thanks for your answer! I followed step by step the video, but I have a trouble when I add the record field after the fv!item. The video creator could create it and had no trouble

  • 0
    Certified Lead Developer
    in reply to carlosp5114

    I do not see how this error is triggered.

  • I include my entire code, remaining the same error:

    a!localVariables(
      local!data,
      {
      a!gridLayout(
        label: "Invoice Details",
        headerCells: {
          a!gridLayoutHeaderCell(label: "Purchase Order"),
          a!gridLayoutHeaderCell(label: "Date"),
          a!gridLayoutHeaderCell(label: "Total Value"),
          a!gridLayoutHeaderCell(label: "Material"),
          a!gridLayoutHeaderCell(label: "Supplier"),
          a!gridLayoutHeaderCell(),
          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:"ICON"),
          a!gridLayoutColumnConfig(width:"ICON")
          
        },
        rows: a!forEach(
          items: local!data,
          expression: a!gridRowLayout(
            contents: {
              a!textField(
                value:fv!item['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{ab97d392-b365-425a-a0e5-116da756c87a}id_orden'], 
                saveInto: fv!item['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{ab97d392-b365-425a-a0e5-116da756c87a}id_orden'],
                required: true                    
              ),
              a!textField(
                value:fv!item['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{25003162-d3d0-4466-86f8-471cb1e37589}fecha_orden'], 
                saveInto: fv!item['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{25003162-d3d0-4466-86f8-471cb1e37589}fecha_orden'],
                required: true                    
              ),
              a!textField(
                value:fv!item['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{c228ed4c-21cb-4af4-a313-88f26e7874da}total_orden'], 
                saveInto: fv!item['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{c228ed4c-21cb-4af4-a313-88f26e7874da}total_orden'],
                required: true                    
              ),
              a!textField(
                value:fv!item['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{5f4060f6-827d-41b5-88e7-0328ec1309bc}Material'], 
                saveInto: fv!item['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{5f4060f6-827d-41b5-88e7-0328ec1309bc}Material'],
                required: true                    
              ),
              a!textField(
                value:fv!item['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{d9317466-7426-47af-bd64-22a998c636e6}id_proveedor'], 
                saveInto: fv!item['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{d9317466-7426-47af-bd64-22a998c636e6}id_proveedor'],
                required: true                 
    
              ),
              a!richTextDisplayField(
                value: {
                  a!richTextIcon(
                  icon: "times-circle",
                  link: a!dynamicLink(
                    saveInto: local!data,
                    value: remove(local!data, fv!index)
                  ),
                  linkstyle: "STANDALONE",
                  color: "NEGATIVE",
                  showwhen: a!isNullOrEmpty(fv!item['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{ab97d392-b365-425a-a0e5-116da756c87a}id_orden'])
                  )
                , 
                  a!richTextIcon(
                   icon: "trash",
                   color: "NEGATIVE",
                   showWhen: a!isNotNullOrEmpty(
                     fv!item['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{ab97d392-b365-425a-a0e5-116da756c87a}id_orden']),
                     
                   link: a!dynamicLink(
                     saveInto: local!data,
                     value: remove(local!data, fv!index)
                   )
                   
                )
                }
              ),
              a!richTextDisplayField(
                value: a!richTextIcon(
                  showWhen: a!isNotNullOrEmpty(
                    fv!item['recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines.fields.{ab97d392-b365-425a-a0e5-116da756c87a}id_orden']),
                  icon: "floppy-o",
                  color: "POSITIVE"
                )
              )
            }
          )
        ),
        addrowlink: a!dynamicLink(
          saveInto: local!data,
          value: append(
            local!data, 
           'recordType!{d269796e-dcd7-46b6-8ecf-55ed16bf54a1}PTPP Invoice Lines'()
          ),
          label: "Add new Invoice Line"
        )
        ),
      a!buttonArrayLayout(
        align: "END",
        buttons: {
          a!buttonWidget(
            label: "Write to the Database",
            style: "PRIMARY",
            saveInto: a!writeRecords(
              records:local!data,
              onSuccess: a!save(local!data, fv!recordsUpdated)
            ),
            validate:true
          )
        }
      )
    }  
    )     

  • 0
    Certified Lead Developer
    in reply to carlosp5114

    OK. And the error shows up when your do ... what?

  • the error shows up at the moment I replace the a!text field with the record fields

                  a!textField(value:fv!item.idOrden, saveInto: fv!item.idOrden), --->  a!textField(value:fv!item[record])

    Could this error happen because in my record I have different types of data? (text and dates). It´s the only difference I found comparing with the video

Reply Children