Working with subforms and related main form field

Working with subforms and related main form field

Hello.

I'm new in Zoo Creator and i need help. I would like to write a Deluge Script and i have doubts.

In order to track the daily tasks from every employee on my applications I´ve got a registration form called "Daily Report". This registration form has got a "DailyTasks" sub form from which every employee must specify the developed tasks (spend time, description of the work,...., and a last field where the employee can say if this task is a part of an open project).


Daily Report
Employee String
Date Date
Client String
.................


Daily Tasks
Time Integer
TaskDescription String
RelatedProject (It can be null or not)
.......................


On the other hand, I´ve got the registration form specifically for Projects where we save all those that are being made by the company. Every project has several related tasks which are saved in the "ProjectTasks" subform.


Project
Name   String
Area   String
DateOfCreation  Date
.................


ProjectTasks
DateofTask Date
Employee string
Time integer
TaskDescription String


All I want is to implement a Success Event on the "DailyReport" Registration Form. I have to assess the "RelatedProject" field of every registration in the subform. In case it is not null, I want to insert this register on the related "ProjectTasks". How I relate the record to insert into the table "ProjectTasks" with the corresponding project?


For instance it can go as follows:

Event On_Success form DailyTasks

for each x in DailyTasks
{
if (x.RelatedProject != Null)
{
insert into ProjectTasks
Added_User = zoho.loginuser
DateofTask=DailyReport.Date
Employee=DailyReport.Employee
Time=x.hours
TaskDescription=x.TaskDescription
]; 
}
}
My question is: How do I match the different lines that I am going to insert into the"ProjectTasks" registration subform with the related Project?   

Sorry my english.

Regards!