Update data from multiple rows in bulk

I create an editable grid where i can see the data of my CDT "Client" (red square) and the relationship or related data from CDT "Vendor" (blue square).

Now I want to select many rows to call a related or record  action to UPDATE the selected fields in the black square. (don't add more rows or delete, just UPDATE)

The data of the editable grid table comes from a form from another interface.

For example, in the image below, I select 3 rows, then for those 3 selected rows, then click a button or link to call a preconfigured related action to update the values in the black square.

The idea of this is to use the select to call a related record or action for bulk actions instead of making changes row by row.

Is it possible using a editable grid or a real only or is there another way to do the same?

  Discussion posts and replies are publicly visible

Parents Reply Children
  • I created a read only selectable grid, when I choose a row I can see the details of each of the selected rows, it works fine (image bellow)

    Now, for selected rows only I want to UPDATE some fields of those selected rows instead of updating row by row,

    I guess I should add a button or link to call a related or record action to UPDATE the selected rows (blue pen on the image).

    At this part I have no idea how to write the expression to update the fields of the selected rows...

    This is the expresión of  the interface

    {
      a!localVariables(
        local!selection,
        local!selectedEmployees,
        {
          a!richTextDisplayField(
            label: "",
            labelPosition: "COLLAPSED",
            value: {
              a!richTextHeader(
                text: "CDT VENDORS"
              )
            }
          ),
          a!columnsLayout(
            columns:{
              a!columnLayout(
                contents:{
                  a!gridField(
                    label: "List of vendors",
    
                    data: 'recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor',
                    columns: {
                      a!gridColumn(
                        label: "primaryKeyID",
                        sortField: 'recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{9dceb98e-8309-43e2-8850-2361b5249976}oecvendorid',
                        value: fv!row['recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{9dceb98e-8309-43e2-8850-2361b5249976}oecvendorid'],
                        align: "END"
                      ),
                      a!gridColumn(
                        label: "Estado",
                        sortField: 'recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{ddd2c258-2bb2-4211-bbb1-e87288f221ac}oecvendorstatus',
                        value: fv!row['recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{915d07c7-d5eb-4ac4-b54d-88f7e5bf833d}oecvendorverffinancial'],
                        align: "START"
                      ),
                      a!gridColumn(
                        label: "Oecvendorselection",
                        sortField: 'recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{f378d12a-175c-4e2f-8c41-a9c87069115e}oecvendorselection',
                        value: fv!row['recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{f378d12a-175c-4e2f-8c41-a9c87069115e}oecvendorselection']
                      ),
                      a!gridColumn(
                        label: "Oecvendornumexpediente",
                        sortField: 'recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{142cf048-fd71-4100-9057-ec8256779079}oecvendornumexpediente',
                        value: fv!row['recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{142cf048-fd71-4100-9057-ec8256779079}oecvendornumexpediente']
                      ),
                      a!gridColumn(
                        label: "Oecvendorexaminador",
                        sortField: 'recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{b8573abe-249a-4e83-98e9-01d9685fd4d4}oecvendorexaminador',
                        value: fv!row['recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{b8573abe-249a-4e83-98e9-01d9685fd4d4}oecvendorexaminador']
                      ),
                      a!gridColumn(
                        label: "Oecvendorcost",
                        sortField: 'recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{f1a8729e-0abb-4e9f-82c3-ba29b693de1d}oecvendorcost',
                        value: if(
                          isnull(fv!row['recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{f1a8729e-0abb-4e9f-82c3-ba29b693de1d}oecvendorcost']),
                          fv!row['recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{f1a8729e-0abb-4e9f-82c3-ba29b693de1d}oecvendorcost'],
                          fixed(fv!row['recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{f1a8729e-0abb-4e9f-82c3-ba29b693de1d}oecvendorcost'], 2)
                        ),
                        align: "END"
                      )
                    },
                    pageSize: 25,
                    selectable: true,
                    selectionValue: local!selection,
                    selectionSaveInto: {
                      local!selection,
                      a!save(local!selectedEmployees, append(local!selectedEmployees, fv!selectedRows)),
                      a!save(local!selectedEmployees, difference(local!selectedEmployees, fv!deselectedRows))
                    },
                    refreshAfter: "RECORD_ACTION",
                    showSearchBox: true,
                    showRefreshButton: true
                  )
                }
              ),
              a!columnLayout(
                contents:{
                  a!richTextDisplayField(
                    label: "Selected vendors",
                    value: {
                      if(
                        or(isnull(local!selectedEmployees), length(local!selectedEmployees) = 0),
                        a!richTextItem(
                          text: "None",
                          style: "EMPHASIS"
                        ),
                        a!forEach(
                          local!selectedEmployees,
                          {
                            a!richTextIcon(
                              icon: "USER-CIRCLE",
                              color: "ACCENT"
                            ),
                            "  ",
                            a!richTextItem(
                              text: {fv!item['recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{9dceb98e-8309-43e2-8850-2361b5249976}oecvendorid']&" "&
                                     fv!item['recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{f378d12a-175c-4e2f-8c41-a9c87069115e}oecvendorselection']}
                            ),
                            char(10)
                          }
                        )
                      )
                    }
                  )
                },
                width: "NARROW"
              )
            },
            stackWhen: {
              "PHONE",
              "TABLET_PORTRAIT"
            }
          )
        }
      )
    }

  • 0
    Certified Lead Developer
    in reply to danna3499

    In your button you'd have something along the lines of,

    a!save(ri!selectedIds, local!selection)

    ri!selectedIds --> array of integer; saving into a PV of the same type.  Then query the data in-process, update the necessary column(s), and write back to the DB using a WTDS node.

  • I think I'm so close to finishing my app, please

    I create this form interface whit two sections  (image bellow)

    1st section a selectable read-only grid 

    2nd section an editable grid that is loaded with the data based on the rows selected in the first section, where I can update the selected fields.

    This is the expression of my interface 

    a!localVariables(
      local!selectedEmployees,
      local!selection,
      local!submitted: false,
    
    
      a!formLayout(
        label: "Form",
        contents: {
          a!sectionLayout(
            label: "Section",
            contents: {
    
              a!columnsLayout(
                columns:{
                  a!columnLayout(
                    contents:{
                      a!gridField(
                        label: "List of vendors",
    
                        data: 'recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor',
                        columns: {
                          a!gridColumn(
                            label: "primaryKeyID",
                            sortField: 'recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{9dceb98e-8309-43e2-8850-2361b5249976}oecvendorid',
                            value: fv!row['recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{9dceb98e-8309-43e2-8850-2361b5249976}oecvendorid'],
                            align: "END"
                          ),
                          a!gridColumn(
                            label: "Estado",
                            sortField: 'recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{ddd2c258-2bb2-4211-bbb1-e87288f221ac}oecvendorstatus',
                            value: fv!row['recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{ddd2c258-2bb2-4211-bbb1-e87288f221ac}oecvendorstatus'],
                            align: "START"
                          ),
                          a!gridColumn(
                            label: "Oecvendorselection",
                            sortField: 'recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{f378d12a-175c-4e2f-8c41-a9c87069115e}oecvendorselection',
                            value: fv!row['recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{f378d12a-175c-4e2f-8c41-a9c87069115e}oecvendorselection']
                          ),
                          a!gridColumn(
                            label: "Oecvendornumexpediente",
                            sortField: 'recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{142cf048-fd71-4100-9057-ec8256779079}oecvendornumexpediente',
                            value: fv!row['recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{142cf048-fd71-4100-9057-ec8256779079}oecvendornumexpediente']
                          ),
                          a!gridColumn(
                            label: "Oecvendorexaminador",
                            sortField: 'recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{b8573abe-249a-4e83-98e9-01d9685fd4d4}oecvendorexaminador',
                            value: fv!row['recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{b8573abe-249a-4e83-98e9-01d9685fd4d4}oecvendorexaminador']
                          ),
                          a!gridColumn(
                            label: "Oecvendorcost",
                            sortField: 'recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{f1a8729e-0abb-4e9f-82c3-ba29b693de1d}oecvendorcost',
                            value: if(
                              isnull(fv!row['recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{f1a8729e-0abb-4e9f-82c3-ba29b693de1d}oecvendorcost']),
                              fv!row['recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{f1a8729e-0abb-4e9f-82c3-ba29b693de1d}oecvendorcost'],
                              fixed(fv!row['recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{f1a8729e-0abb-4e9f-82c3-ba29b693de1d}oecvendorcost'], 2)
                            ),
                            align: "END"
                          )
                        },
                        pageSize: 25,
                        selectable: true,
                        selectionValue: local!selection,
                        selectionSaveInto: {
                          local!selection,
                          a!save(local!selectedEmployees, append(local!selectedEmployees, fv!selectedRows)),
                          a!save(local!selectedEmployees, difference(local!selectedEmployees, fv!deselectedRows))
                        },
                        refreshAfter: "RECORD_ACTION",
                        showSearchBox: true,
                        showRefreshButton: true,
                        rowHeader: 1
                      )
                    }
                  ),
    
                },
                stackWhen: {
                  "PHONE",
                  "TABLET_PORTRAIT"
                }
              )
    
            }
          ),
          a!sectionLayout(
            label: "Section",
            contents: {
    
              a!gridLayout(
                headerCells: {
                  a!gridLayoutHeaderCell(label: "VENDOR", align: "RIGHT"),
                  a!gridLayoutHeaderCell(label: "numexp", align: "RIGHT"),
                  a!gridLayoutHeaderCell(label: "abono", align: "RIGHT")
                },
                columnConfigs: {
                  a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
                  a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
                  a!gridLayoutColumnConfig(width: "DISTRIBUTE")
                },
                rows: a!forEach(
                  items: local!selectedEmployees,
                  expression:{
                    a!gridRowLayout(
                      id: fv!index,
                      contents: {
    
                        a!textField(
                          label: "VENDOR " & fv!index,
                          value: fv!item['recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{9dceb98e-8309-43e2-8850-2361b5249976}oecvendorid'],
                          readOnly: true,
                          align: "RIGHT"
                        ),
                        a!textField(
                          label: "numexp " & fv!index,
                          value: fv!item['recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{142cf048-fd71-4100-9057-ec8256779079}oecvendornumexpediente'],
                          saveInto: fv!item['recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{142cf048-fd71-4100-9057-ec8256779079}oecvendornumexpediente'],
                          readOnly: false,
                          align: "RIGHT"
                        ),
                        a!textField(
                          label: "abono " & fv!index,
                          value: fv!item['recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{138380fa-dbae-487a-b521-997f734d5610}oecvendorabono'],
                          saveInto: fv!item['recordType!{2a5b03b9-f095-4d78-9105-b987408087a2}CWA OEC Vendor.fields.{138380fa-dbae-487a-b521-997f734d5610}oecvendorabono'],
                          readOnly: false,
                          align: "RIGHT"
                        )
    
                      }
                    )
                  }
                ),
                selectionSaveInto: {},
                selectable: false,
                validations: {},
                shadeAlternateRows: true,
                rowHeader: 1
              ),
              a!textField(
                label: "Selected Values",
                labelPosition: "ADJACENT",
                instructions: typename(typeof(local!selection)),
                value: local!selection,
                readOnly: true
              )
    
    
    
            }
          )
        },
        buttons: a!buttonLayout(
          primaryButtons: {
            a!buttonWidget(
              label: "Submit",
              saveInto: a!save(ri!CWA_OECVendor,local!selectedEmployees),
              submit: true,
              style: "PRIMARY"
            )
          },
          secondaryButtons: {
            a!buttonWidget(
              label: "Cancel",
              value: true,
              saveInto: ri!cancel,
              submit: true,
              style: "NORMAL",
              validate: false
            )
          }
        )
      )
    )
    

    After modifying or updating the selected fields I create a button to submit the form and save the changes.

    For this I created a process model (image below), but in the WTDS node I get an error and I can't save the submitted form.

    The process model process

    PDF

  • 0
    Certified Lead Developer
    in reply to danna3499

    You wouldn't do the querying in the "value" field for the PV - you'd want to put a query in a Script Task in a Data Output and save the result into your PV array from there.