Hi, I have multiple CDTs that have various relationships set up. What I am not clear on is how the ids that would enable the records to relate appropriately are passed from the parent CDT to the child CDT? For example, if an app allows you to create a customer and that customer has many phone numbers, I would have a parent CDT with a one to many relationship with a phone number CDT. When a user enters information into the form, how should the customer key flow into the phone number CDT to allow the relationship to work? Is it expected that this occurs automatically, or would you just program for this where a script task runs in the process model to add the applicable customer id into the applicable phone number rows in the child CDT? (i.e. script task using: repeat(count(pv!childCDT),pv!parentCDT.id)
THANKS!
Discussion posts and replies are publicly visible
lcrostarosa I may not have explained my initial question well but essentially the key linking the child CDT to my parent CDT was not populating as I expected it to. I went away from this method after researching it more extensively. I found what ManuelHTG found, which was that it was not as easy/clean of a methodology as I initially thought it would be. I did end up just using the process model and script task functionality to grab the parent key and put it in the child CDT. This resulted in a much cleaner process and so far has enabled me to do everything I need. So for anyone looking to do something similar, it seems the best method is to just us the process model to grab the parent keys and put them into the child CDTs.
Hi.I am facing same issue.can you please explain me how you stored the primary key of first cdt and saved it in the second data store entity.
ankitt
first data store entity just remove save into from input tab and in the output tab stored vales just do data pass back to PV
after that you can use script task in output tab just map first cdt primarky key to second cdt of foreign key .then you can continue with store data to second data store entity
Appian manages the child key automatically. Your nested phone record could be populated in an editable grid as shown below inside your customer grid. You will notice that nowhere the customer id (key) is being referenced.
a!gridLayout( label: "Phone Records", labelPosition: "ABOVE", emptyGridMessage: "No records found.", headerCells: { a!gridLayoutHeaderCell(label: "Phone Number") }, columnConfigs: { a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 5) }, rows: a!forEach( items: fv!item.phoneFK, /* fv!item is your customer variable, depending on how you set it up, it could very well be customer.phoneFK */ expression: a!gridRowLayout(contents: { a!textField() }) ), addRowLink: a!dynamicLink( label: "Add Phone", saveInto: a!save( target: fv!item.phoneFK, value: append( fv!item.phoneFK, 'type!{urn:com:appian:types:APP}PHONECDT'() ) ) )),