When adding dynamic fields via addFormField, you have the option of identifying the tab ID. However, this is not an easy thing to derive having to go into the HTML source to find tab IDs.
When you bundle custom records which have custom tabs (or you add custom subtabs in Setup > Customization > Subtabs), they do not keep their assigned IDs when they transfer to the new environment, thus code which adds the dynamic field and tries to assign to one of these tabs needs to be modified to identify the new ID in the new environment.
If you identify a tab ID that is invalid, NetSuite throws an 'unexpected error' instead of gracefully ignoring or throwing a descriptive error for the problem.
Here's what I'd love to have for the new year.
1. A way to assign IDs to custom tabs just as we do for custom fields. This way when used in a bundle, they retain their assigned ID and code doesn't break. Also, I now can easily see and find the ID associated with a specific tab I want to create a dynamic field on.
2. Handle bad tab ID gracefully. Stop throwing 'unexpected error'. It offers no value what so ever and basically means you need to start troubleshooting line by line. Either gracefully ignore or throw a descriptive error (e.g. 'tab id is invalid').
Happy New Year...