Hi!
I want to update a progress bar with a value retrieved from DB. For this, I use a Expression Rule that gives me this data.
To update the progress bar I use a button to update the progress bar value, calling the Expression Rule. I save this return value on a a local Variable and uses it to update the progress bar values. The problem is that the return value of the Expression rule is only returned the first time I called it or when I refresh the page, which is the same. After this, I can't refresh the local variable value.
Anyone knows why this happens?
Thanks in advance, here is my interface code:
a!localVariables( local!rpaProgressRefresh: rule!FSA_GetRPAProgressByCovidAreaId( ri!FSA_CovidArea.id ), local!rpaProgress: a!refreshVariable( value: rule!FSA_GetRPAProgressByCovidAreaId( ri!FSA_CovidArea.id ), refreshAlways: true() ), { a!sectionLayout( label: "RPA Data", contents: { a!columnsLayout( columns: { a!columnLayout( contents: { a!integerField( label: "Total Recovered Cases", labelPosition: "ABOVE", value: ri!FSA_CovidArea.totalRecoveredCases, readOnly: true ), a!integerField( label: "Active Cases", labelPosition: "ABOVE", value: ri!FSA_CovidArea.activeCases, readOnly: true ) }, width: "MEDIUM_PLUS" ), a!columnLayout( contents: { a!integerField( label: "New Recovered Cases", labelPosition: "ABOVE", value: ri!FSA_CovidArea.newRecoveredCases, readOnly: true ) } ) } ), a!columnsLayout( columns: { a!columnLayout( contents: {}, width: "WIDE" ), a!columnLayout( contents: {} ) } ) }, divider: "BELOW" ), a!sectionLayout( label: "RPA Progress", contents: { a!buttonArrayLayout( buttons: { a!buttonWidget( label: "Update RPA Progress", icon: "refresh", value: rule!FSA_GetRPAProgressByCovidAreaId( ri!FSA_CovidArea.id ), saveInto: { local!rpaProgressRefresh }, submit: false, style: "NORMAL" ) }, align: "START" ), rule!FSA_RPA_ProgressBar( local!rpaProgress ) }, showWhen: ri!isInRPA, divider: "BELOW" ) } )
Discussion posts and replies are publicly visible
I think the value in line 68 is not refreshed. I suggest to use an a!save() with value set to your rule in line 72 to fetch the data.
I tried it. But the value wasn't refreshed.
Code like below did not refresh?
saveInto: { a!save( target: local!rpaProgressRefresh, value: rule!FSA_GetRPAProgressByCovidAreaId( ri!FSA_CovidArea.id ) ) },
No it isn't refreshing.
What is the code within rule!FSA_GetRPAProgressByCovidAreaId()? Based on what we're seeing, I'm guessing there might be a load() used within that rule.
This is the code of the Expression Rule:
a!localVariables( local!rpaProgress: a!queryEntity( entity: cons!FSA_RPA_COVID_AREA_PROGRESS_ENTITY, query: a!query( logicalexpression: a!queryLogicalExpression( operator: "AND", filters: { a!queryFilter( field: "covidAreaId", operator: "=", value: ri!covidAreaId ) }, ignoreFiltersWithEmptyValues: true ), pagingInfo: a!pagingInfo( startIndex: 1, batchSize: 50 ) ), fetchTotalCount: false ).data, {local!rpaProgress.tasksCompleted, local!rpaProgress.totalTasks} )
Ok, so it's not that.
Second question: why are you running the same query twice, once into local!rpaProgress and once for local!rpaProgressRefresh? It seems as though the latter isn't actually used for anything.