Skip to main content
November 29, 2023
Question

Inquiry Regarding Creating Historical Records When Writing to Existing Records in a Process Model

  • November 29, 2023
  • 8 replies
  • 0 views

I hope this email finds you well. I am currently working on a project involving the use of a process model to write records. While I understand that, by default, matching primary keys result in the overwriting of existing records, my specific objective is to partially overwrite data in the existing record and simultaneously create a new record with a different historical record type.

Could you kindly provide guidance on the recommended approach or configuration to achieve this purpose?

Thank you in advance for your time and support.

8 replies

stefanhelzle0001
Brainy
November 29, 2023

Without knowing any details, I can think of two options.

Do you plan to keep both records in the same database table? What about related data?

Create an expression in Appian that takes the original record and returns two copies. One with the same primary key and some updates, the other with an empty primary key and the necessary adjustments.

Or, create a trigger in the database that inserts a new item, instead of an in-place update.

December 1, 2023

Thank you for your response.

I will be working with two different data tables. The intended process is to retrieve data 2 from table 1 using input data 1 as the key. I will then subtract input data 3 from data 2 and update the result as the value of data 2 in table 1. In addition, all input data will be written to table 2. If this explanation seems unclear, we will give a concrete example later.

I encountered a problem with the data retrieval not working when using the following code:

a!queryRecordType(
recordType: 'recordType!Table1',
fields: { 'recordType!Table1Data2'
},
filters: a!queryFilter(
field: 'recordType!Table1Data1',
operator: "=",
value: pv!Data1
),
pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 500)
).data['recordType!Table1Data2']


Your help in resolving this issue would be greatly appreciated. Thank you very much.

December 1, 2023

Hi @r7x7djutejjh0001,

The code is correct for giving the required output,
Can you please check the value you are passing in pv!Data1 has any corresponding data in the table?