@sasrsc1966
First, I'd recommend a Form rather than a hand made patch formula. It will make your PowerApp life simpler!
However, if you are using a Patch statement for the Parent record, then that will already return the ID. You need not spend any more time trying to get it from the list.
i.e. Set(varLastSubmitID, Patch(......).ID)
If ID is blank, then it failed. Otherwise it will return the ID.
That can then be used in your other formula.
Your ForAll is backward - you are using it like a ForLoop in development. It is not, it is a function that returns a table of records based on the schema you want. Using it like a ForLoop on the patch will cause your performance to suffer.
Formula should be:
// now submit customers
Patch(Customers,
ForAll(colCustomers,
{
Name: Name,
TicketRequestId: varLastSubmitID
}
)
);
The CountRows is a waste of time as if it is empty (zero) then the Patch will do nothing anyway.
The Defaults is a waste as Patch observes the ID of the record you provide. If there is none, it will create a record.
The only reason you need Defaults is if you have defined default values in your list.
IF you have a real need for Defaults, then it would be incorporated into your formula as:
// now submit customers
Patch(Customers,
ForAll(colCustomers,
Patch(Defaults(Customers),
{
Name: Name,
TicketRequestId: varLastSubmitID
}
)
)
);
Overall, I would recommend using the Gallery instead of a collection. The gallery will already contain all the data you need and this will keep you from wasting time on writing formulas in OnChange actions and such to update a collection. All of that is just extra work.
If you have a specific need for it, then by all means. But otherwise, keep it super simple and PowerApps will be your friend.