Thanks for the post.
Out of my curious brain...is there a reason you want to do this in a script instead of just making the Jobs::TotalInvoiced field a calculation field of "Sum(Sales Invoices::AmountUSD)"
You could have a portal in your Jobs table with Invoices and Amounts in the portal. Then have a Calculation field on the layout with total amount invoiced. No script needed.
If there's another reason why you must have a script...note that I don't see anywhere in your script where you use the $$SUM variable to do anything. You haven't said: SetField[JobNumbers::TotalInvoiced;$$Sum] anywhere in the script. You calculated what you wanted...but didn't park it anywhere on the record, just in the script variable that will be overwritten on the next loop through.
Thanks Ninja, quite easier with your solution!
As for what I needed a script, I guess it is simply because I just discovered FM and didn't know it was so easy to use!