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: "" ) )
Discussion posts and replies are publicly visible
Why not just call that integration inside the saveInto of that button? There is no need to complicate things with this local variables construct.
I've tried that
a!localVariables( local!loggedInUserVar: fn!loggedInUser(), local!isLoading: false, local!isValid: false, 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 */, a!save( local!isValid, rule!UWM_Map_Calculate_Data( caseId: ri!case.caseId, loggedInuserVar: local!loggedInUserVar ), ) }, disabled: local!isLoading/* Disable button while loading */ ) }, align: "START", marginBelow: "NONE" ), { a!richTextDisplayField( labelPosition: "COLLAPSED", value: a!richTextItem( text: { fn!tostring(local!isValid) }, style: "STRONG" ), ) } } ) }, ), )
What is this expression doing? Can you share the code?
Absolutely!
a!localVariables( local!integrationResponse: rule!UWM_POST_Calculate( caseId: ri!caseId, updatedByUserId: rule!UWM_Get_User_Id(username: ri!loggedInUserVar), updatedByUserFullName:rule!UWM_Get_Full_Name(user: ri!loggedInUserVar), ), /* Extract the result from the body dictionary */ local!result: index(local!integrationResponse, "body.result", false), /* Return the appropriate type based on the result */ if( local!result, local!result, false ) )
OK. That name "UWM_Post_Calculate" points to an integration that might have been configured to "Modify Data". If this is true, and that integration does NOT modify any data, I suggest to change that configuration to "Queries Data" and this should just work.
That did it! Thank you so much!