Hi everyone
i m struggling with the process modeling when i need to write multiple rows in a DB ,
i have a CDT of "Documents" which i put as an array in my form and a CDT of "creditRequest" which contains an array of the Documents CDT.
i need to put both of them in seperate databases , the first one is the documents which i want to store and then after to store the creditrequest which will contain the documents.
now when i debugging my process i can see that my documents don't have an ID after that it s passing the "write to db",
and then after i have problem with the creditrequest ,
how i need to do for write the multiple documents that i want to write in the db and then write them in the next Db of Creditrequest ???
Discussion posts and replies are publicly visible
here we go. i can recommend the follow approach:Please use "stored values" and select the process variable you used before as "value" you like to store on the "Input" tab. pv!creditRequest.-> then use a scrip task (output tab) and extract the data you like to have in another pv
can you show me please how you do thart ?
Pretty simplestep 1:step 2:in your case "demoPv" would be "CreditRequest"and newPV your "document" process variable. attention: "newpv" and demoPv.XXXX need to be of the same type of simple data type or cdt.
In general I think the comments here are overcomplicating this. Since you have a nested 1:M relationship, you usually don't need to have multiple operations to write to the database. Instead, writing to the top level creditRequest should also write to your document table.
One thing just to check: if you go to your CDT for creditRequest and you click on the key icon next to the documents field. When you open that dialog, can you confirm - do you have this checkbox selected for "Updates to a parent value should also update associated child value(s)"? If so that means that a single write to data store will update both creditRequest and documents.
If that checkbox is selected, back your process just remove the write to the document entity and just perform the write to creditRequest. In addition, save the output for Stored Values back into the process variable for your credit request, and you should see all of the IDs populated.
okay i get you
i did what you said i changed the process to test , i also checked my CDT as you said i checked the key and it was already selected
i removed the write to the document , and at the end of the process it didn't give me an error at the end, i got the id s cool ,
but when i m looking in the db i see something strange i have null in the table of credit request
whereas in the table of document i can see them, we can see also in last coloumn of this table the id of the request
can you explain me please if you understand what is mean ?
My guess is that column in creditRequest is a leftover from an earlier version of your CDTs. In this instance I would expect that the creditRequest table should NOT have any reference to the documents table at all because of the way relationships work: if you have a one-to-many relationship, the foreign key should be in the child table (document).
I would expect that you could remove that column padcments_idcreditrequiest_id and there would be no effect for any of your CDTs