Skip to main content
Known Participant
Jan 20, 2025 5:04 PM UTC
Question

Get DB data from a form called in a long process seems not working

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

9 replies

stefanhelzle0001
Brainy
Jan 20, 2025 8:07 PM UTC

I need to see actual code to fully understand what you are doing here.

Known Participant
Jan 20, 2025 9:14 PM UTC

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
          )
        )
      }
    )
  }
)


What to do :

- open the form

- 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

stefanhelzle0001
Brainy
Jan 21, 2025 7:09 AM UTC

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.

andrewh6762
Participating Frequently
Jan 20, 2025 10:23 PM UTC

Just a shot in the dark, are you using a combination of data store entity and records when you write/get? One thing that could cause the issue is writing with data store entity and retrieving with an unsynced record.

Known Participant
Jan 21, 2025 7:00 AM UTC

No, we do not have Record sync. And my little example does have any either