Hi,
I have a long process (long running task) which calls a User Input Task to display a Main form with a text field.
In that Interface I have a Related Action which calls a process to display a modal form, and when it is submitted, this later saves a new Text value in DB.
When the modal form is closed, and I get back to the main form, my text field is not refreshed with the new data.
So I've tried this little test in the Main form :
- On the saveInto of my textField I've added a writeRecords smartService to save data in the DB, and I've added a "GET" Button to get Data from DB (dynamicLink).
If I enter a new value in my TextField, I can see that WriteRecords works fine, and the new value is well saved in DB (viewing it in phpMyAdmin),
Then, if I click on the GET button, the underlying Expression Rule (EXPR1) gets some old data (why ? if the DB shows me correct data)
If I execute the same EXPR1 outside of my execution process form (from Appian Designer), the retrieved DATA are correct (the new value)
(for this test, I did not used Rule Input, I'm just using testing local variables).
Why I cannot get my Data directly from DB?What am I missing ?
----
This subject is linked to this previous thread
Appian Community
Discussion posts and replies are publicly visible
I need to see actual code to fully understand what you are doing here.
The code of our Customer is very big and private, so I've created a little example:Here is the main form call by a little process which contains only an User Input Task :
a!localVariables( local!model: null, { a!sectionLayout( label: "Vehicle", contents: { a!columnsLayout( columns: { a!columnLayout( contents: { a!textField( label: "Vehicle id", value: ri!vehicle.id, labelPosition: "JUSTIFIED", readOnly: true ), a!textField( label: "Model", value: ri!vehicle.model, saveInto: { ri!vehicle.model, a!writeToDataStoreEntity( dataStoreEntity: cons!CJT2_Entity_Vehicle, valueToStore: ri!vehicle, onSuccess: { } ), }, labelPosition: "JUSTIFIED", refreshAfter: "UNFOCUS", validations: {} ), a!textField( label: "Model from DB", value: local!model, labelPosition: "JUSTIFIED", readOnly: true ), a!cardLayout( contents: { a!textField( label: "Get DATA form DB", readOnly: true ) }, style: "INFO", link: a!dynamicLink( saveInto: a!localVariables( local!vehicle: rule!CJT2_GetVehicleById( id: ri!vehicle.id ), if( a!isNotNullOrEmpty(local!vehicle), a!save(local!model, local!vehicle.model), null ) ) ) ), } ), a!columnLayout( contents: {} ), a!columnLayout( contents: {} ) } ) } ), /*Buttons*/ a!sectionLayout( contents: { a!buttonLayout( primaryButtons: { a!buttonWidget_23r3( label: "Save", icon: "check", saveInto: { }, submit: true, style: "PRIMARY", disabled: false, showWhen: true ) }, secondaryButtons: a!buttonWidget_23r3( label: "Cancel", value: true, saveInto: ri!cancel, submit: true, showWhen: true, validate: false ) ) } ) } )
- Enter a new vehicle model (the model is immediately saved in DB)
- Click on the "Get Data" Button to get the new data from DB : does not work and retrieve the previous data
This might be because of that unnecessary local variables in line 49. Please try to add a refreshVariable on that local!vehicle and set refreshAlways to true.
Thank you Stefan, you're right
Cool! Local variables can introduce a unexpected caching behaviour in certain situations. E.g. when writing expressions to encapsulate a API query, I try to avoid locals or at least add refreshAlways to make sure that API call actually happens, even when passing the same set of parameters.
Yes indeed, few years ago, I had already encountered this kind of difficulty, it just comes back to me.Thank you for this advice