I have a script that creates new lead records but I'm getting the below error when I try to add an address sub record.
You have attempted an invalid sublist or line item operation. You are either trying to access a field on a non-existent line or you are trying to add or remove lines from a static sublist.
I am new to scripting but have followed the documentation but can't see where I've gone wrong.