With Summer 15 release coming up quickly, and the HTML markup area going away on home page components, I wanted to pose this question. I have some code markup that makes it so that a button disappears on the quote page once the submit for approval button is clicked by the user. I asked Salesforce Support if this could be accomplished any other way, and they said that it could not. I find that hard to believe and was wondering if anyone had any ideas on how I could accomplish this. Currently I have this code in an HTML area home page component:
<!-- We can locate this div with the script below, traverse up the DOM and then hide the entire sidebar component. -->
<div id="sidebarComponentLocator">If you see this, something is broke with Dynamic Button functionality.</div>
<!-- Import jQuery from google CDN, could also be static resource-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
/*Immediately create a unique alias for this version of jQuery to prevent conflicts with other js libraries*/
var j$ = jQuery.noConflict();
/*Determine what type of object is currently being displayed on the page. Only confident way to do this is get object prefix */
var objectPefix = window.location.href.substring( window.location.href.indexOf('.com/') + 5, window.location.href.indexOf('.com/') + 8 );
/*Query the records from Dynamic_Button__c object as soon as possible, don't wait for DOM ready event*/
var result = sforce.connection.query("Select Button_Name__c, Field_Id__c, Field_Value__c from Dynamic_Button__c where Object_Prefix__c = '" + objectPefix + "'");
var records = result.getArray("records");
/*Execute this code block once page DOM has fully loaded*/
j$(document).ready(function(){
/*Hide the sidebar last as this is lowest priority. First priority is show/hiding the buttons.
Find the sidebarComponentLocator, then find parent div with class 'sidebarModule' and the hide it*/
j$("#sidebarComponentLocator").closest(".sidebarModule").hide().prev().hide();
/*First loop through the dynamic button records and hide any that are on the layout. We must first hide all the buttons
as the Dynamic Button records only contan the 'show' logic*/
for (var i = 0; i< records.length; i++) {
/*Hide buttons define in Dynamic_Button__c object*/
j$("input[name='"+ records[i].Button_Name__c.toLowerCase() +"']").hide();
}
/*Now loop through the Dynamic_Button_Records and show button if field value matches that define in record*/
for (var i = 0; i< records.length; i++) {
/*Get the value from the field on the page layout*/
var recordValue = j$("#"+records[i].Field_Id__c+"_chkbox").attr('title');
var showValue = records[i].Field_Value__c;
/*Show the button if the value of the field on this record matchs the setting in the Dyamic_Button__c*/
if(recordValue == showValue){
j$("input[name='"+ records[i].Button_Name__c.toLowerCase() +"']").show();
}
}
}
</script>
Appreciate any help! Thanks.