write multiple rows in database in process modeling

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

Parents
  • 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 Slight smile

Reply
  • 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 Slight smile

Children
No Data