Skip to main content
charletonh0001
March 21, 2022
Solved

Create Record Action saves to database but does not appear in grid until a Data Sync is done

  • March 21, 2022
  • 18 replies
  • 2 views

I have created a simple table in the same database as aavehicle and I created a data model for the table along with CREATE and UPDATE record actions.  When I add a new record using the CREATE record action and associated UI, the data does not appear in the record List until after I run a Data Sync.  When I UPDATE a record using the UPDATE record action and associated UI, the changes are reflected immediately in the record List.  I have scrolled through all pages of the list and confirmed the new record does not appear.  If I query the database BEFORE running the Data Sync, the new record is in the database.  Any ideas why this may be happening?

Best answer by charletonh0001

After additional trial and error, I was able to figure this out myself.  I will explain the solution here in case anyone else has a similar situation. 

The database table I created was using a guid for the primary key.  When I initially established the Create Record Action it was failing because of missing not nullable data.  Since I couldn't figure out how to generate a guid in Appian, I allowed the column to be nillable on insert from Appian by editing the XSD for the data type and then I added a database trigger to set the key value on insert.  After creating a new Data Type that used an integer for the primary key and testing the Create Record Action it worked and it finally dawned on me that the record was not returned to the grid after insert because Appian didn't know the key value for the record that was inserted. 

To fix the problem, I created an expression rule to generate a guid, then modified the Process Model to use a Script Task that sets the key value using the expression prior to the Write new Code to DSW call and removed the trigger code to prevent overwriting of the key value sent by Appian.  Now that the key value is established in Appian, it can return the record that was inserted immediately after save.  Problem is now resolved.

18 replies

gopalk2865
Participating Frequently
March 22, 2022

Hi, An immediate sync will occur anytime Appian writes to the database table.An immediate sync will only refresh the data that was changed by Appian.

charletonh0001
March 22, 2022

Hello!  Thank you for responding!  I cannot find an "immediate sync" option on the Data Sync page of my record type.  I am using Appian 22.1.  The only options I find under Data Sync are Sync Schedule (which allows a scheduled to be established for daily sync) and Start Sync to manually run a data sync.  Can you please tell me where to find the option for enabling "Immediate sync"?  Thanks!

gopalk2865
Participating Frequently
March 22, 2022

 "immediate sync" happens as soon as you update , add or delete the record.You dont need to re-sync the record. You can just refresh the record using refresh button like below snap,

There is also a functionality where you can configure refresh interval . 

Though i am unsure about auto refresh after any record action.

viraty527193
March 22, 2022

Hi charletonh0001

If the data sync is enabled, any CRUD operation using the related actions of the record will trigger the sync and data will be updated. Sometimes it fails which you can see in the sync history.

Can you try to update/ create something using the related action of the record and have a look at the sync history, If it will fail you will see the status in the data sync tab under sync history.

charletonh0001
March 22, 2022

Hi!  Thanks for your response.  After adding the new record through the Create record action, there is no new sync history row.  If I click the START SYNC button, the new record is returned from the database and a new row is added to the Sync History.  I expected the sync to happen immediately once I clicked the submit button when added a new record, but it is not.  It does immediately sync when I use the Update record action, but not Create.  When I add a new record, the only way I can get the  new record into the grid is to perform a manual sync.

viraty527193
March 22, 2022

Can you check it in the Records Tab of Tempo, whether the new record is coming up there after you create it? If it appears in the Tempo, in the grid try to set the "refreshAfter" in the grid to "RECORD_ACTION"

refreshAfter:"RECORD_ACTION"

charletonh0001
charletonh0001AuthorAnswer
March 22, 2022

After additional trial and error, I was able to figure this out myself.  I will explain the solution here in case anyone else has a similar situation. 

The database table I created was using a guid for the primary key.  When I initially established the Create Record Action it was failing because of missing not nullable data.  Since I couldn't figure out how to generate a guid in Appian, I allowed the column to be nillable on insert from Appian by editing the XSD for the data type and then I added a database trigger to set the key value on insert.  After creating a new Data Type that used an integer for the primary key and testing the Create Record Action it worked and it finally dawned on me that the record was not returned to the grid after insert because Appian didn't know the key value for the record that was inserted. 

To fix the problem, I created an expression rule to generate a guid, then modified the Process Model to use a Script Task that sets the key value using the expression prior to the Write new Code to DSW call and removed the trigger code to prevent overwriting of the key value sent by Appian.  Now that the key value is established in Appian, it can return the record that was inserted immediately after save.  Problem is now resolved.