Refresh grid with data from recorType after record deletion

Certified Lead Developer

Hi all,

Here are my needs:

I have a grid of records with checkboxes and a button. I woud like to delete selected records and refresh the grid.

Deletion works good. Refresh does not work.

I read alreqy these 3 posts with problems similas to mine,  without finding a solution:

What i did so far is to create a read only grid. Data are retriven from a recordType, relying directly from the DS. 

Clicking on checkboxes stores record ids on a local variable.

The button invokes a PM who does other operations before deleting checked records from DS.

All branches in PM are chained up to the delete step.

here the button:

    a!buttonWidget(
              label: "Delete",
              icon: "trash",
              saveInto: {
                a!startProcess(
                  processModel: cons!PM_deleteRequests,
                  processParameters: {
                    requestsToBeDeleted: local!selectedRequests
                  },
                  onSuccess: {
                    a!save(local!succes, local!succes + 1),
                    a!save(local!selectedRequests, null())
                  },
                  onError: a!save(local!error, true())
                )

Here are the parameters:

         selectable: true,
          selectionStyle: "CHECKBOX",
          selectionValue: local!selectedRequests,
          selectionSaveInto: local!selectedRequests,
          validations: {},
          spacing: "DENSE",
          height: "AUTO",
          borderStyle: "STANDARD",
          refreshAlways: false,
          refreshAfter: "RECORD_ACTION",
          refreshOnVarChange: local!succes,
    /* I tried these last 3 param each one alone and in combination*/
          showSearchBox: false,
          showRefreshButton: false,
          recordActions: {}
        )
 

here how a field in the grid is invoked:

            a!gridColumn(
              label: "Document Title",
              sortField: 'recordType!Request.fields.{documentTitle}documentTitle',
              value: fv!row['recordType!Request.fields.{documentTitle}documentTitle'],
              align: "START"
            ),

Any hint/help is welcome

Thanks A lot

Ale

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    The automatic refresh works for record action fields only. You will have to refresh the data manually. I typically add a local called "refreshCounter", then fetch the data for the grid an a local variable which is then refreshed if that counter is incremented. Feed that locally stored data to the data attribute of the grid.

  • 0
    Certified Lead Developer
    in reply to Stefan Helzle

    I tried to spool the query in the local!data variable at the beginning.

      local!datarefresh: 0,
      local!data: a!refreshVariable(
      value: a!recordData(
        recordType: 'recordType Request',
        filters: a!queryLogicalExpression(
          operator: "AND",
          filters: {
            a!queryFilter(
              field: 'recordType Request.fields.{endDate}endDate',
              operator: "is null"
            ),
            a!queryFilter(
              field: 'recordType! Request.fields.{active}active',
              operator: "=",
              value: true
            )
          },
          ignoreFiltersWithEmptyValues: true
        )
      ),
     refreshOnVarChange: local!datarefresh
      ),

    Then into the button, on succes i increase local!datarefresh variable to arrange an update

     a!startProcess(
                      processModel: cons!PM_deleteRequests,
                      processParameters: {
                        requestsToBeDeleted: local!selectedRequests
                      },
                      onSuccess: {
                        a!save(local!datarefresh, local!datarefresh + 1),
                        a!save(local!selectedRequests, null())
                      },
                      onError: a!save(local!error, true())
                    )

    The in the grid, i fetch local!data as data:

     a!gridField(
              data: local!data,
              columns: ...
              initialSorts:...
              secondarySorts:..
                selectable: true,
              selectionStyle: "CHECKBOX",
              selectionValue: local!selectedRequests,
              selectionSaveInto: local!selectedRequests,
              validations: {},
              spacing: "DENSE",
              height: "AUTO",
              borderStyle: "STANDARD",
              /*refreshAlways: true(),*/
              refreshOnVarChange: local!datarefresh,
              /*refreshAfter: "RECORD_ACTION",*/
        /*the 3 options above had been tested in any possible combination*/
              showSearchBox: false,
              showRefreshButton: false,
              recordActions: {}
            )
          },

    No way, refresh does not happen.

    What's wrong?

    thanks a lot

Reply
  • 0
    Certified Lead Developer
    in reply to Stefan Helzle

    I tried to spool the query in the local!data variable at the beginning.

      local!datarefresh: 0,
      local!data: a!refreshVariable(
      value: a!recordData(
        recordType: 'recordType Request',
        filters: a!queryLogicalExpression(
          operator: "AND",
          filters: {
            a!queryFilter(
              field: 'recordType Request.fields.{endDate}endDate',
              operator: "is null"
            ),
            a!queryFilter(
              field: 'recordType! Request.fields.{active}active',
              operator: "=",
              value: true
            )
          },
          ignoreFiltersWithEmptyValues: true
        )
      ),
     refreshOnVarChange: local!datarefresh
      ),

    Then into the button, on succes i increase local!datarefresh variable to arrange an update

     a!startProcess(
                      processModel: cons!PM_deleteRequests,
                      processParameters: {
                        requestsToBeDeleted: local!selectedRequests
                      },
                      onSuccess: {
                        a!save(local!datarefresh, local!datarefresh + 1),
                        a!save(local!selectedRequests, null())
                      },
                      onError: a!save(local!error, true())
                    )

    The in the grid, i fetch local!data as data:

     a!gridField(
              data: local!data,
              columns: ...
              initialSorts:...
              secondarySorts:..
                selectable: true,
              selectionStyle: "CHECKBOX",
              selectionValue: local!selectedRequests,
              selectionSaveInto: local!selectedRequests,
              validations: {},
              spacing: "DENSE",
              height: "AUTO",
              borderStyle: "STANDARD",
              /*refreshAlways: true(),*/
              refreshOnVarChange: local!datarefresh,
              /*refreshAfter: "RECORD_ACTION",*/
        /*the 3 options above had been tested in any possible combination*/
              showSearchBox: false,
              showRefreshButton: false,
              recordActions: {}
            )
          },

    No way, refresh does not happen.

    What's wrong?

    thanks a lot

Children