hacking Archives - Justin Silver https://www.justinsilver.com/tag/hacking/ Technology, Travel, and Pictures Tue, 27 Oct 2015 20:17:54 +0000 en-US hourly 1 https://wordpress.org/?v=6.0.1 https://www.justinsilver.com/wp-content/uploads/2013/06/cropped-apple-touch-icon-160x160.png hacking Archives - Justin Silver https://www.justinsilver.com/tag/hacking/ 32 32 Hide Edit/Del Links on Salesforce Standard Page https://www.justinsilver.com/technology/salesforce/hide-edit-del-link-on-salesforce-standard-pages/?utm_source=rss&utm_medium=rss&utm_campaign=hide-edit-del-link-on-salesforce-standard-pages https://www.justinsilver.com/technology/salesforce/hide-edit-del-link-on-salesforce-standard-pages/#comments Thu, 13 Nov 2014 00:36:35 +0000 http://justinsilver.com/?p=3831 It is not possible to control the visibility of the Edit/Del action links for a related list. On a VisualForce page you can insert your own CSS or Javascript to control the display, which...

The post Hide Edit/Del Links on Salesforce Standard Page appeared first on Justin Silver.

]]>
AmpedSense.OptimizeAdSpot('AP'); AmpedSense.OptimizeAdSpot('IL'); AmpedSense.OptimizeAdSpot('IR');

It is not possible to control the visibility of the Edit/Del action links for a related list. On a VisualForce page you can insert your own CSS or Javascript to control the display, which you can also do on a Salesforce standard layout, albeit in a slightly more complicated fashion.

The trick is to use a Custom Link on your Home Page Layout. This Custom Link is defined as an onClick, but will actually load code inline with the use of REQUIRESCRIPT. Inside the REQUIRESCRIPT will be our Javascript payload, Base64 encoded.

Create Javascript Payload

First let’s compile the Javascript we need to control the UI on standard page layouts. In this case we want to hide the Edit/Del links on a related list, so view the page and use your developer tools to look at the DOM. You want to find the ID of the top level element in the related list table, something like “500c0000004BtmN_00sE0000004gkgq_body”. Use the following snippet as an example.

jQuery(document).ready(function($){
	// hide this sidebar module
	$('#sidebarDiv div.linksModule').each(function(){
		var $module = $(this);
		if ( $module.find('.brandPrimaryFgr').text()=='UserInterfaceInjection'){
			$module.hide();
			return false;
		}
	});
	// hide the Edit/Del links
	jQuery('#500c0000004BtmN_00sE0000004gkgq_body .actionColumn').hide();
});

Now we need to convert this to Base64. Any way is fine, but online is pretty easy: https://www.base64encode.org/.

alF1ZXJ5KGRvY3VtZW50KS5yZWFkeShmdW5jdGlvbigkKXsNCgkvLyBoaWRlIHRoaXMgc2lkZWJhciBtb2R1bGUNCgkkKCcjc2lkZWJhckRpdiBkaXYubGlua3NNb2R1bGUnKS5lYWNoKGZ1bmN0aW9uKCl7DQoJCXZhciAkbW9kdWxlID0gJCh0aGlzKTsNCgkJaWYgKCAkbW9kdWxlLmZpbmQoJy5icmFuZFByaW1hcnlGZ3InKS50ZXh0KCk9PSdVc2VySW50ZXJmYWNlSW5qZWN0aW9uJyl7DQoJCQkkbW9kdWxlLmhpZGUoKTsNCgkJCXJldHVybiBmYWxzZTsNCgkJfQ0KCX0pOw0KCS8vIGhpZGUgdGhlIEVkaXQvRGVsIGxpbmtzDQoJalF1ZXJ5KCcjNTAwYzAwMDAwMDRCdG1OXzAwc0UwMDAwMDA0Z2tncV9ib2R5IC5hY3Rpb25Db2x1bW4nKS5oaWRlKCk7DQp9KTs=

Put this text aside, we will need it later when creating the Javascript link.

Create Custom Link

Visit Setup > Home > Customize > Custom Links

  1. Create a new Link
  2. Name: UserInterfaceInjection
  3. Behavior: Execute Javascript
  4. Content Source: onClick Javascript
  5. Body: {!REQUIRESCRIPT('data:application/javascript;base64,BASE64_JS')}, except that you want to replace BASE64_JS with your Base64 encoded Javascript.

Create Home Page Component

Visit Setup > Home > Home Page Components

  1. Create a new Component
  2. Name: UserInterfaceInjection
  3. Type: Links
  4. Choose UserInterfaceInjection Link

Add to Home Page Layout

Visit Setup > Home > Home Page Layouts

  1. Edit your layout to include UserInterfaceInjection

Now when you visit your page the Action column should be hidden from your related list. It’s pretty easy to see how this could be further expanded to add all kinds of custom functionality to standard Page Layouts in Salesforce.

The post Hide Edit/Del Links on Salesforce Standard Page appeared first on Justin Silver.

]]>
https://www.justinsilver.com/technology/salesforce/hide-edit-del-link-on-salesforce-standard-pages/feed/ 10