Skip to main content
March 30, 2023
Solved

Creating records based on other record

  • March 30, 2023
  • 9 replies
  • 0 views

I have a Process Model that creates a record. That record has a field "record types", which can be A, B, or C. Based on which record type is selected, I would like to create a record from a related table with additional inputs. I have tried following this documentation: https://docs.appian.com/suite/help/23.1/Write_Records_Smart_Service.html#create-records-and-related-records, but there is a lot that it leaves out. 
Here is an example. If the Record Type is A, the process forks down to "Create A record".

My problem is creating the A record. The A table has a 1-1 relationship with the Record table.
Some specific questions I have are:
What should the process variables be set up like for this? 
How should the "Create A record" Data section be set up for this process?
Both tables have Auto Incrementing IDs, is any additional setup needed for this on the actual Appian platform? If so, what?
Are there any additional services or processes needed to accomplish this? 

Best answer by davel001150

You can output the records that were created as the output of the first write node.  Then, in a script task in between the two, update the A Record with the ID from the one that was written, then you can write it too.  With a 1-to-1 relationship, the FK has to be on one of them.  The one with the FK has to be the one that's written second, with its FK populated from the script task in between.

9 replies

davel001150
March 30, 2023

You can output the records that were created as the output of the first write node.  Then, in a script task in between the two, update the A Record with the ID from the one that was written, then you can write it too.  With a 1-to-1 relationship, the FK has to be on one of them.  The one with the FK has to be the one that's written second, with its FK populated from the script task in between.

March 30, 2023

Thank you, that is very helpful. Unfortunately, the current setup is to where the FK for A, B, C, etc are on the Record table, so I will have to do some reconfiguration, but not the end of the world. Just to be sure and for future reference, do you know this process is possible in any other way with the current setup?
Current Setup:
Record:
PK recordID
FK aID
FK bID
FK cID

A
PK aID

B
PK bID

C
PK cID

davel001150
March 30, 2023

Write A, or B, or C first as needed, based on conditional logic, then update the FK on the main record, then write it.  I assume that the FKs are all potentially null, because you have a 0-1-to1 relationship.  Each of the 3 possible conditional writes has an outflow that all goes to the same script task that updates the main one.  It only gets a little more complicated and might need OR and AND gateways if there's potential to sometimes save A and B or B and C or all 3.