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

    You could write an expression rule that takes the CDT as an input and returns the Record Type with all the fields mapped appropriately.

    Ideally, you would be using Record Types everywhere to avoid having to do this.

  • Thanks for your answer! The fact is that I had to make an editable grid with the function append in order to add new rows. I followed a tutorial and they used data store in order to make the local variables. I would prefer to do everything only with records, as you said before, but I´m new in appian and, even though I tried to substitute everything and use a record, I have problems in some lines, specially in the function append. 

    How could I substitute the array for the record in my code? Any help would be useful, thank you so much!

    I show you the editable grid code so you can understand my problem:

     

    a!localVariables(
    local!gridDataType: 'type!{urn:com:appian:types:PTPP}PTPP_INVOICE_LINES'(),

    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!Array_InvoiceLines,
    expression: a!gridRowLayout(
    contents: {
    a!textField(value:fv!item.idOrden, saveInto: fv!item.idOrden),
    a!textField(value:fv!item.fechaOrden, saveInto: fv!item.fechaOrden),
    a!textField(value:fv!item.totalOrden, saveInto: fv!item.totalOrden),
    a!textField(value:fv!item.material, saveInto: fv!item.material),
    a!textField(value:fv!item.idProveedor, saveInto: fv!item.idProveedor),
    a!richTextDisplayField(
    value: a!richTextIcon(
    icon: "times-circle",
    color: "NEGATIVE",
    link: a!dynamicLink(
    saveinto: a!save(
    target: ri!Array_InvoiceLines, value: remove(
    ri!Array_InvoiceLines, fv!index
    )
    )
    )
    )
    )
    }
    )
    )

    },
    selectionSaveInto: {},
    addRowLink: a!dynamicLink(
    label: "Add new Invoice Line",
    saveinto: a!save(target: ri!Array_InvoiceLines, append(ri!Array_InvoiceLines, local!gridDataType))
    ),
    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!localVariables(
      local!gridDataType: 'type!{urn:com:appian:types:PTPP}PTPP_INVOICE_LINES'(),
    
      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!Array_InvoiceLines,
                expression: a!gridRowLayout(
                  contents: {
                    a!textField(value:fv!item.idOrden, saveInto: fv!item.idOrden),
                    a!textField(value:fv!item.fechaOrden, saveInto: fv!item.fechaOrden),
                    a!textField(value:fv!item.totalOrden, saveInto: fv!item.totalOrden),
                    a!textField(value:fv!item.material, saveInto: fv!item.material),
                    a!textField(value:fv!item.idProveedor, saveInto: fv!item.idProveedor),
                    a!richTextDisplayField(
                      value: a!richTextIcon(
                        icon: "times-circle",
                        color: "NEGATIVE",
                        link: a!dynamicLink(
                          saveinto: a!save(
                            target: ri!Array_InvoiceLines, value: remove(
                              ri!Array_InvoiceLines, fv!index
                            )
                          )
                        )
                      )
                    )
                  }
                )
              )
    
            },
            selectionSaveInto: {},
            addRowLink: a!dynamicLink(
              label: "Add new Invoice Line",
              saveinto: a!save(target: ri!Array_InvoiceLines, append(ri!Array_InvoiceLines, local!gridDataType))
            ),
            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 also include images of the code. Thanks!

    With this code, I am able to add rows and put values into it, but I´m not able to upload the data in my record after that. I repplied in the next message (Stefan Helzle) and added the new code using records, in which I have error

    Thank you again, best regards

Reply
  • a!localVariables(
      local!gridDataType: 'type!{urn:com:appian:types:PTPP}PTPP_INVOICE_LINES'(),
    
      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!Array_InvoiceLines,
                expression: a!gridRowLayout(
                  contents: {
                    a!textField(value:fv!item.idOrden, saveInto: fv!item.idOrden),
                    a!textField(value:fv!item.fechaOrden, saveInto: fv!item.fechaOrden),
                    a!textField(value:fv!item.totalOrden, saveInto: fv!item.totalOrden),
                    a!textField(value:fv!item.material, saveInto: fv!item.material),
                    a!textField(value:fv!item.idProveedor, saveInto: fv!item.idProveedor),
                    a!richTextDisplayField(
                      value: a!richTextIcon(
                        icon: "times-circle",
                        color: "NEGATIVE",
                        link: a!dynamicLink(
                          saveinto: a!save(
                            target: ri!Array_InvoiceLines, value: remove(
                              ri!Array_InvoiceLines, fv!index
                            )
                          )
                        )
                      )
                    )
                  }
                )
              )
    
            },
            selectionSaveInto: {},
            addRowLink: a!dynamicLink(
              label: "Add new Invoice Line",
              saveinto: a!save(target: ri!Array_InvoiceLines, append(ri!Array_InvoiceLines, local!gridDataType))
            ),
            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 also include images of the code. Thanks!

    With this code, I am able to add rows and put values into it, but I´m not able to upload the data in my record after that. I repplied in the next message (Stefan Helzle) and added the new code using records, in which I have error

    Thank you again, best regards

Children
No Data