Note: there are no global fields in your script. You are using variables. They work just fine for what you are doing but they aren't fields and they aren't global.
You can enclose each section of your script inside an If block that keeps that code from executing if your variable is empty.
If [ Not IsEmpty ($SecondGlobalDate) ]
Set field (DataTable::CustomerID; $CustomerID_FK_)
Set field (DataTable::Date;$SecondGlobalDate)
(Big) slip of the keyboard - glad we both knew what I meant!
Thanks for the help there, works like a charm