Skip to main content
September 14, 2022
Question

Update data from multiple rows in bulk

  • September 14, 2022
  • 6 replies
  • 2 views

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?

6 replies

September 15, 2022

You can pass the primary key id of the selected rows to the subprocess which you will call on related action and in that form, fetch the data for those ID's and update it and send it back to DB.

danna3499Author
September 15, 2022

HI, Deepak

Should I use a read-only grid or an editable grid...?

Could you help me with the basic expression to adapt it in my workflow...?

danna3499Author
September 15, 2022

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"
        }
      )
    }
  )
}