I am having a dynamic button on home page side bar problem. I am not much into Jscript and Jquery so any help would be appreciated. I have a button which needs to be displayed only to few users based on certain criteria. I have pasted the code below this is happening because of the SFDC getting away with HTML home page components.
Error i am getting is - If you see this, something is broke with Dynamic Button functionality. and the button is visible to all user.
If you see this, something is broke with Dynamic Button functionality. /*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 ); /*Determine object ID this is being submitted for. */ var objectID = window.location.href.substring( window.location.href.indexOf('.com/') + 5, window.location.href.indexOf('.com/') + 23 ); /*if this is an Lead fetch the Lead HeadTeam_Approval_Status__c and only show buttons for opps that are not 'In Progress' */ var showButton = true; if(opjectPrefix = '00Q'){ var oppStatus = sforce.connection.query("Select HeadTeam_Approval_Status__c from Lead where id = '" + objectID + "'"); var oppRecords = oppStatus.getArray("records"); if(oppRecords.length > 0){ if(oppRecords[0].HeadTeam_Approval_Status__c == 'In Progress'){ showButton = false; } } } /*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, User__c from Dynamic_Button__c where Object_Prefix__c = '" + objectPefix + "'"); var records = result.getArray("records"); /*get the current user object to use later*/ var user = sforce.connection.getUserInfo(); var userId = user.userId; /*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
if(opjectPrefix = '00Q'){
. I think it should be==
instead of=
.