I tried to replicate the issue today by extracting the same records from Production and reinserting them into my Sandbox. I was unsuccessful in causing the error. This further made me think the issue was with bad data in the record. I reviewed all fields on the record and discovered somehow I was able to import Production Ids into the Sandbox where the Id should have been invalid. Basically the CustomerSignedBy Id had the Contacts Production Id which does not exist in our Developer Sandbox org.
When I double click on the field the data disappears and when I click save it shows "Deleted" in that field. I test the button again and the errors is gone. So the answer to the question is yes invalid data can cause a custom button to error.
Steps to replicate the issue:
- Export a Contract Record from Production with the CustomerSignedId populated.
- Import the Contract Record into a Developer Sandbox and map the CustomerSignedId fields.
- Use a custom button to create a new related record.
UPDATE: Ticket opened with Salesforce, they were able to replicate the import of an invalid Id into the CustomerSignedBy field, which is the root cause of this issue.
UPDATE II: Heard back from Salesforce today and they have turned this into a known issue and are still investigating. Until they find a fix, just make sure you are careful about importing invalid id's into lookup fields using some type of data loader as it can cause unexpected behavior.