Oh my god. It's full of code!

Salesforce Custom Button Create Error

Someone on twitter recently was wondering how to create an error from a custom button click, similar to visualforce errors. Turns out it is actually really quite easy, no jQuery or any complexity really required. This will write text of your choosing to the div set up by Salesforce to display data errors, and show the div as well. Just create a custom button, set it to execute javascript (of course) and paste in this code. I imagine your button will do some other stuff, but this will make nice errors for you (man that sounds like an oxymoron).

var errorDiv = document.getElementById('errorDiv_ep');
errorDiv.innerHTML = 'Error Happened';
errorDiv.style.display = 'block';

Pretty simple eh?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s