Issues Fetching Emial ID in a sub form using a fuction in delgue

Issues Fetching Emial ID in a sub form using a fuction in delgue

Hi All, I have two forms: Form A and Form B. Form B is a subform in Form A.

In Form B, I have a lookup field (Action For) from another creator application. I am looking to populate a field (Email ID) in Form B based on user selection in the Lookup field.

I have a workflow for Form A > Created or edited > User input of Subform (B).Lookup field 

ActionEmail= Createrapplication.ExternallCall.function(input.subform.lookupfeild)
row.Email_ID =ActionEmail

Issues:
In Form A, when I add a row for Subform, the Emial is populated for the first row; however, as soon as I add another row and select the lookup field, the Emial ID field is populated with the row 1 selection. 

If I try the below deluge, I get an error " Row" is a system keyword and cannot be used.

For each row in Sub_form
{
ActionEmail= Createrapplication.ExternallCall.function(input.subform.lookupfeild)
row.Email_ID =ActionEmail
}