Run integration only when users clicks a button on interface

I have a scenario where the users is viewing an interface from a record action.   Before they click submit to complete the record action I want them to click a button that will call an integration and that value returned will either allow them to submit or not (it is a backend validation process).   Everything I am trying I run into issues because the refresh variable.


The code: 

a!localVariables(
  local!loggedInUserVar:fn!loggedInUser(),

  local!isLoading: false,
  local!isValid: a!refreshVariable(
    value: if(
      local!isLoading,
     
            rule!UWM_Map_Calculate_Data(
            caseId: ri!case.caseId,
            loggedInuserVar: local!loggedInUserVar
        
        ),
     
      false
    ),
    refreshOnVarChange: local!isLoading,
    refreshAlways: true,
   
  ),
 
  a!columnsLayout(
    columns: {
      a!columnLayout(
        contents: {
          a!sectionLayout(
            contents: {
              a!cardLayout(
                contents: {
                  a!buttonArrayLayout(
                    buttons: {
                      a!buttonWidget(
                        label: "Button",
                        icon: "check-double",
                        style: "OUTLINE",
                        saveInto: {
                          a!save(local!isLoading, true) /* Start loading state */
                        },
                        disabled: local!isLoading /* Disable button while loading */
                      )
                    },
                    align: "START",
                    marginBelow: "NONE"
                  ),
                }
              )
            },
          ),
        },
        width: "MEDIUM_PLUS"
      )
    },
    spacing: ""
  )
)


And the error on button click:  Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error in rule 'uwm_map_calculate_data': An error occurred when creating local!integrationResponse. a!save() and smart service functions cannot be used in a local variable unless "refreshAlways" is true for that local variable using the a!refreshVariable() function.

I've tried multiple different ways of achieving this but it always keeps coming back to this error.   Any suggestions on fixing this code OR achieving this in another way would be greatly appreciated

  Discussion posts and replies are publicly visible

Parents Reply Children
No Data