Refresh Interface after a!startProcess does not work

Certified Senior Developer

Hi,

We have a simple interface wich contains a refresh button that triggers a a!startProcess() function (to update some fields in Db and then update fields in the GUI). 
The interface is displayed from a RecordType view.
The process gets some data and then write simply the current datetime into an updated_on field in the table. 
The problem we met is when we click on the button, the data are not refreshed (or works just the first time). 
When we debug the variables in the interface we can see that the data are still the Old ones despite the fact the data are correct in the Db table. 
If we click again and again, the data are never refreshed. 
I've tried a lot of things :
- add a counter in the interface to ensure the save is called when the process ended
- all the process nodes are well chained. 
- I've deleted a lot of nodes in the process so that now it contains only 5 nodes (to be sure, to avoid the 50 nodes issues). 
- I've created a little testing snippet example and all works fine in another environment (with a Site, a RecordType, a process, a simple Interface and the Vehicle CDT example).

Would you have any idea why this problem occurs ? 


Regards 

  Discussion posts and replies are publicly visible

Parents Reply
  • 0
    Certified Senior Developer
    in reply to Mike Schmitt

    Here it is:

    a!localVariables(
      local!cdt: a!refreshVariable(
        value: a!queryEntity(
          entity: cons!AS_DSE_HISTORY,
          query: a!query(
            logicalExpression: a!queryLogicalExpression(
              operator: "AND",
              filters: {
                a!queryFilter(
                  field: "history_id",
                  operator: "=",
                  value: ri!historyId,
                  applyWhen: a!isNotNullOrEmpty(ri!historyId)
                ),
              }
            ),
            pagingInfo: a!pagingInfo(
              startIndex: 1, 
              batchSize: - 1,
              sort: a!sortInfo("history_id", true)
            )
          )
        ).data,
        refreshAlways: ri!refreshAlways
      ),
      local!cdt, /* I just keep this local!var for the Example */
    )

Children
  • 0
    Certified Lead Developer
    in reply to cedric01

    May I ask the question of what purpose this local variable has? You can just leave it away and avoid the hassle with the refreshes.

  • 0
    Certified Senior Developer
    in reply to Stefan Helzle

    Stefan, I add a little comment to my code, to avoid you to ask this question ;-)
    this local variable will be used for an updateDictionary needs.

  • +1
    Certified Lead Developer
    in reply to cedric01

    So instead of using refreshAlways, we can just use refreshOnVarChange and pass in a new ri! variable to reference our refreshCounter from the parent.

    a!localVariables(
      local!cdt: a!refreshVariable(
        value: a!queryEntity(
          entity: cons!AS_DSE_HISTORY,
          query: a!query(
            logicalExpression: a!queryLogicalExpression(
              operator: "AND",
              filters: {
                a!queryFilter(
                  field: "history_id",
                  operator: "=",
                  value: ri!historyId,
                  applyWhen: a!isNotNullOrEmpty(ri!historyId)
                ),
              }
            ),
            pagingInfo: a!pagingInfo(
              startIndex: 1, 
              batchSize: - 1,
              sort: a!sortInfo("history_id", true)
            )
          )
        ).data,
        
        refreshOnVarChange: {
          ri!refreshCounter
        }
      ),
      
      local!cdt, /* I just keep this local!var for the Example */
    )

    Then from the parent, instead of having the startProcess onRefresh re-call the expression rule, just pass the refreshCounter in during the original call to the ER in the interface.

    buttons: {
      a!buttonWidget(
        label: "Update",
        icon: "refresh-alt",
        saveInto: {
          a!startProcess(
            processModel: cons!AS_PM_HISTO,
            processParameters: { projetId: ri!projetId },
            onSuccess: {
              /* a!save(
                local!history,
                rule!as_qe_getHistoryWithFilters(
                  projectId: ri!projectId
                )[1]
              ), */
              a!save(
                local!refreshCounter,
                local!refreshCounter + 1
              )
            },
            onError: {
            }
          )
        },
        style: "SECONDARY"
      )
    },

  • 0
    Certified Senior Developer
    in reply to Mike Schmitt

    Thanks a lot Mike, I understand better now

  • 0
    Certified Senior Developer
    in reply to cedric01

    I have another refresh problem in exactly the same context (same interface).
    In this screen I have a button displayed by a Related action.
    The visibility of that action is linked to the data described above.

    Now my data are well refreshed, why this button is not refreshed too ?
    (of course, if I close and reopen the interface back, the button is hided) 

    Is there any way to trigger the refresh of the underlying Record Type?

  • 0
    Certified Lead Developer
    in reply to cedric01
    button displayed by a Related action.

    Can you clarify a bit what you mean by this exactly?

  • 0
    Certified Senior Developer
    in reply to Mike Schmitt

    My interface, is a RecordType view.

    In this latter I have a related Action (let's call it "Enclose") and the visibility condition of this action depends of an ER that gets the History data described above.

    The "Enclose" button is initially displayed.

    So when I click on the Refresh button previously seen, I would need to trigger the refresh of the RecordType, and therefore to refresh the Visibility condition of the Enclose action (recall the ER).

    With the Refresh button, all the data in that interface are now well refreshed, but the "Enclose" button keeps displayed, because the action was not refreshed. 

  • 0
    Certified Lead Developer
    in reply to cedric01

    If you're talking about a related action that shows in the top border of a record view, i'm pretty sure that the data used for that related action's visibility is completely outside of the scope of the local variables in your interface that you're refreshing, etc.  I would expect a browser-level refresh might be needed to get that re-evaluated.

    If you're talking about a related action housed in an on-form Record Action field, then.. well i'm less sure what the interplay is there.  It may do its own evaluation and caching on the back-end ahead of time.

  • 0
    Certified Senior Developer
    in reply to cedric01

    The related action I'm talking about has been added in the interface using the a!recordActionField function :

    a!recordActionField(
    actions: {
      a!recordActionItem(
       action: 'recordType!history.actions.enclose',
       identifier: ri!history.history_id
    ),