Enter a value from one cdt into another and create a script

Hello, 
I'm new to appian and I can not solve a question

I have two tables. The first "request" table has two fields: id (integer), name (text) and document (text). The second table "documentation" also has two fields: iddocum (integer) and docum (text). With a form that has a text field and a field to upload a file, fill both fields and I give the send button. In my database "request" appears an id that is generated only for each shipment you make, the name I have inserted and the document ([Document: 7917]). Also in the other "documentation" table that same one is saved value of the document ([Document: 7917]). Here comes my problem. I want the id generated only from the first table, I can pick it up and save it together with the value of the document at a time. For this last, I have an expression rule that does not work well.
index( index( a! queryEntity ( entity: cons! CPRO_CT_DS_solicitudes, query: a! query ( filter: a! queryFilter ( field: "documentation", operator: "=", value: "[Document: 7945]" ), pagingInfo: a! pagingInfo ( startIndex: 1, batchSize: -1, sort: a! sortInfo ( field: "id", ascending: false ) ) ) ), "data", {} ), "id", null ) I also have a process where I start the form and then with an XOR, I ask: if I have not uploaded a document that finishes my process and if I have uploaded a document, in the script task pick up the id. Do not do this part correctly.

  Discussion posts and replies are publicly visible