@NElliott working with NS CS, and i think this issue is related to SS2.0…i tested this script block in a SS1.0 UE on beforeLoad on the customer record to confirm that the code worked and it was fine. Then tested in SS2.0 and got the same error again.
Then rearranged the order that we are setting the fields and it seems to be ok. I will update here when i have confirmed the exact issue.