Refresh issue variable after calling the WriteToDatastoreEntity service

Hi,

We have a simple code to add a record in a table, and we need to display the total count result stored in a local variable (getting the result from an ER that simply counts the records in the table).

When we execute the code, the record is well added in the table, but the refresh of the variable is not down (or the ER is not called ?).

We are using a count variable to make a refresh with a refreshvariable function but it doet not work.

Are we forgetting something ? 

a!localVariables(
  local!count: 0,
  
  local!nb_element: a!refreshVariable(
    value: rule!CD_Count_CD_Test1(), /* count the nb of records */
    refreshOnVarChange: {
       local!count   
    }
  ),
  
  local!new_bank:
  (
    'type!{urn:com:appian:types:crm}CD_Test1',
    { code: 1, libelle: "Un" }
  ),
  
  local!erreur,
  local!success,
  local!cancel: false,
  {

    a!cardLayout(
      contents: {
        rule!SHARED_CardsTitle(
          icon: "address-book",
          label: "Bank testing"
        ),
        a!boxLayout(
          label: "Add a bank",
          contents: {
            a!columnsLayout(
              columns: {
                a!columnLayout(
                  contents: {
                    a!buttonLayout(
                      primaryButtons: {
                        a!buttonWidget(
                          label: "add",
                          icon: "check",
                          saveInto: {
                            /****************************************************************************************/
                            /* Save the new bank */
                            a!writeToDataStoreEntity(
                              dataStoreEntity: cons!CD_Test1_cons,
                              valueToStore: { local!new_bank },
                              onSuccess: {
                                a!save(local!count, local!count+1),
                                a!save(local!success, now()),
                              },
                              onError: {
                                a!save(local!erreur, now()),
                              }
                            ),
                            /*
                            a!save(
                              local!nb_element,
                              rule!CD_Count_CD_Test1()
                            ),*/
                            
                          },
                          submit: false,
                          style: "PRIMARY"
                        )
                      },
                      secondaryButtons: a!buttonWidget(
                        label: "Cancel",
                        saveInto: {
                          a!save(local!cancel, true),
                        },
                        submit: false,
                        validate: false
                      )
                    )
                  }
                )
              }
            )
          },
          showWhen: true,
          style: "#980000",
          marginBelow: "STANDARD"
        )
        ,
        a!textField(
          value: local!nb_element,
        )
      },
      showWhen: true,
      marginbelow: "STANDARD"
    )
  }
)


Regards

  Discussion posts and replies are publicly visible