Skip to main content
alessandrom1708
October 10, 2022
Solved

Refresh grid with data from recorType after record deletion

  • October 10, 2022
  • 8 replies
  • 0 views

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

Best answer by alessandrom1708

I do reply to my own message to explain how I solved this problem.

The recordType I was using (and so far the only one relying on the DB table of my interest) was of type Data Store Entity.

I created a new RecordType, from wizard I chose to keep the syncronization and then the type was Database.

I created then a new interface from scratch using this new object but, the data parameter in the grid was just a recordtype.

The grid has the parameter refreshOnVarChange: local!success and this local variable is updated each time the user clicks on my custom delete button. 

The process model did not change.

Thanks to [mention:126a676c85024855948336691b0a7b92:e9ed411860ed4f2ba0265705b8793d05], [mention:b45a4f6a20b14a008e4e0ec732a8bf98:e9ed411860ed4f2ba0265705b8793d05] and [mention:5f0a8dbb0bca426c84d1cc871d8b5fc5:e9ed411860ed4f2ba0265705b8793d05] for hints and help.

 

8 replies

stefanhelzle0001
Brainy
October 10, 2022

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.

alessandrom1708
October 10, 2022

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

mikes0011
Brainy
October 10, 2022

This setup looks correct from an initial skim-through.  The one thing you'll need to double-check (which you haven't provided either way here) is that your process has chaining enabled all the way through to the node that performs the "deletion" in the database.  The "onSuccess" save will execute *immediately* upon the first chaining break in the process, and if, for example, you have no chaining set up in the process, it would be happening way too early to be properly caught by your refresh variable setup seen here.

The Expression Guru
October 10, 2022

Have you tried Refresh After parameter in Read Only Grid, if you have given delete action as a record action you can use this parameter available in a!gridField() 

alessandrom1708
October 10, 2022

No way to make it work with refresh after: "RECORD_ACTION".

Either in the read-only box or in a!refreshvariable() function.

alessandrom1708
alessandrom1708AuthorAnswer
October 11, 2022

I do reply to my own message to explain how I solved this problem.

The recordType I was using (and so far the only one relying on the DB table of my interest) was of type Data Store Entity.

I created a new RecordType, from wizard I chose to keep the syncronization and then the type was Database.

I created then a new interface from scratch using this new object but, the data parameter in the grid was just a recordtype.

The grid has the parameter refreshOnVarChange: local!success and this local variable is updated each time the user clicks on my custom delete button. 

The process model did not change.

Thanks to [mention:126a676c85024855948336691b0a7b92:e9ed411860ed4f2ba0265705b8793d05], [mention:b45a4f6a20b14a008e4e0ec732a8bf98:e9ed411860ed4f2ba0265705b8793d05] and [mention:5f0a8dbb0bca426c84d1cc871d8b5fc5:e9ed411860ed4f2ba0265705b8793d05] for hints and help.