Skip to main content

Posts

Creating Super Awesome PDF's with Salesforce

Brief intro Salesforce PDF Salesforce under the hood uses "Flying-Saucer" rendering engine to render the pdf of the fly. Check out more about Flying-Saucer here : It basically supports CSS2.1 and minimal features of CSS3. I would recommend you to go through @Page css properties and this link for a better understanding http://www.antennahouse.com/CSSInfo/CSS-Page-Tutorial-en.pdf Lets get started: Case1 : Repeating Header / Footer In this example we will have our Logo as header and Page number as the footer  which will repeated in all the pages of the document. Demo The Code: <apex:page renderAs="pdf" standardStylesheets="false" showHeader="false" applyHtmlTag="false" > <head> <style> @page { margin-top:70px; margin-left:0px; margin-right:0px; size:portrait;
Recent posts

Solving the Logout back button problem through javascript.

In this blog we will see how to solve the logout back button problem, this is a simple solution to handle but its not robust but still works well less number of pages. Here is the JS for <pre> function preventBack(){          window.history.forward();                   }                   setTimeout("preventBack()", 0);          window.onunload=function(){null}; </pre> Here is the Demo Another way of overcoming this would be adding recaptcha to the login form , even though the form gets resubmitted it will fail at captcha as it would be different for every page load.

Modal popup on click of custom button

Sometimes u need to display some extra information on click of a custom button in a standard salesforce button but a simple javascript alert wouldnt serve the purpose. In some scenarios you need to display some visualforce page and perform some operations . In many scenarios this custom popup modal window will come to your rescue ! To create this pop first create a custom button. For this example I am going to create a custom button opportunity Go to "Opportunities"------>"Buttons, Links, and Actions". Click on "New Button or Link" Type in the label and description for the button For " Display Type " choose "Detail Page Button" For "Behavior" choose "Execute Javascript" For "Content Source" choose "OnClickJavascript" In the code section paste the following code. {! REQUIRESCRIPT(" https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js ")} function show

Restricting the file types upload in salesforce chatter

Restricting the file types upload in salesforce chatter To restrict the file types one option is to write a trigger on "Feeditem". Developing the Trigger: Open developer console ,go to "File"---> "New" --->"Apex Trigger". From the pop-up give the name of the trigger and choose the sObject as "FeedItem" from the dropdown and hit "Submit" Start Coding !! //TRIGGER TO RESTRICT FILE TYPES ON CHATTER trigger restrictFileType on FeedItem (after insert) {                   for(FeedItem fi : Trigger.new)                    {                                  if(fi.ContentType == 'text')                                            fi.addError('You are not allowed to upload this kind of file');                    } } You can further enhance the code by adding multiple file types in custom settings and refer it in the trigger instead of hardcoding in the trigger. Happy Coding !!!!!