Skip to content

Instantly share code, notes, and snippets.

@bolaurent
Last active April 4, 2018 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bolaurent/65e3f59ac81ee2587a7d67a2d372996e to your computer and use it in GitHub Desktop.
Save bolaurent/65e3f59ac81ee2587a7d67a2d372996e to your computer and use it in GitHub Desktop.
Salesforce Developer Console menus not working fix
<apex:page docType="html-5.0" id="thepage">
<script src="//cdnjs.cloudflare.com/ajax/libs/jsforce/1.7.0/jsforce.min.js"></script>
<apex:form id="theform">
<apex:pageblock id="thepageblock">
<apex:pageblockButtons location="top" id="buttons">
<apex:commandButton value="Delete my IDEWorkpace"
onclick="deleteIDEWorkspace()"
disabled="True"
id="deletebutton"
/>
</apex:pageblockButtons>
<apex:pageBlockSection id="section">
<apex:pageblocksectionitem id="item1">
<apex:outputlabel value="IDEWorkspace ID:" styleclass="bold"/>
<apex:outputtext value="not found" id="IdDisplay" />
</apex:pageblocksectionitem>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
<apex:outputPanel id="emptypanel">
</apex:outputPanel>
<script>
var conn = new jsforce.Connection({ accessToken: '{!$Api.Session_Id}' });
var workspaceId;
var deleted = false;
var button = document.getElementById('{!$Component.thepage.theform.thepageblock.buttons.deletebutton}');
var notFoundMessage = 'No IDEWorkspace found for your user';
var idDisplay = document.getElementById('{!$Component.thepage.theform.thepageblock.section.item1.IdDisplay}');
conn.tooling.query("select id, name, createdbyid from ideworkspace where createdbyid = '{!$User.Id}'",
function(err, result) {
if (err) { alert(err); }
else if (result.totalSize > 1) {
alert('Query returned multiple IDEWorkspaces ' + JSON.stringify(result));
}
else if (result.totalSize < 1) {
idDisplay.innerHTML = notFoundMessage;
}
else {
// exactly one IDEWorkspace found for this user
workspaceId = result.records[0].Id;
console.log(workspaceId);
button.className = "btn";
button.disabled = false;
document.getElementById('{!$Component.thepage.theform.thepageblock.section.item1.IdDisplay}').innerHTML = workspaceId;
}
});
function deleteIDEWorkspace() {
conn.tooling.query("select id, name, createdbyid from ideworkspace where createdbyid = '{!$User.Id}'",
function(err, result) {
if (err) { alert(err); }
else if (result.totalSize > 1) {alert('Query returned multiple IDEWorkspaces ' + JSON.stringify(result));}
else if (result.totalSize < 1) {alert('Could not determine Id of your IDEWorkspace');}
else {
console.log(workspaceId);
console.log("deleting...");
conn.tooling.sobject('IDEWorkspace').delete(workspaceId, function(err, ret) {
if (err || !ret.success) { return console.error(err, ret); }
alert('Deleted IDEWorkspace Successfully : ' + ret.id);
button.className = "btnDisabled";
button.disabled = false;
});
}
});
}
</script>
</apex:page>
@bolaurent
Copy link
Author

You know how sometime the Salesforce Developer Console hangs up? And if you look at the javascript console, you see that it has encountered an error and silently crashed? Salesforce help gives a procedure for fixing this, but it's kind of a pain.

This VisualForce page gives you a button that will fix it for you.

@bolaurent
Copy link
Author

Uses the amazing https://jsforce.github.io library.

@bolaurent
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment