Posts

Showing posts from 2015

How to remove and Delete row from PageBlock table on VF page

<apex:page controller="Classname" sidebar="false">    <style> .Processing { position: fixed; background: url('/img/loading32.gif'); background-repeat: no-repeat; background-position: center; width: 100%; height: 100%; z-index: 1004; left: 0%; top: 0%; } </style> <apex:Form id="frmId"> <apex:actionstatus id="statusProcessing" startstyleclass="Processing"></apex:actionstatus> <apex:pageBlock id="blockTD"> <apex:variable var="delrowNumber" value="{!0}"/>  <apex:pageBlockTable value="{!lstofData}" var="objTB"> <apex:column headerValue="Action"> <apex:commandLink value="Del" style="color:red" action="{!delRow}" immediate="true" reRender="blockTD" status="statusProcessing" > <ap

Only Number enter in Input text on VF page

Using javascript you can validate only number will be enter in text box <apex:page> <script>    function numbersonly(e)         {              var unicode=e.charCode? e.charCode : e.keyCode;                if (unicode!=8 )             {                  if ((unicode<48||unicode>57))                        return false;                              }                   }                       </script> <apex:form> <apex:inputText value="{!xxx}" onkeypress="return numbersonly(event);"> </apex:form> <apex:page>   Sumit Shukla sumitshukla.mca@gmail.com skypeID: shuklasumit1 Mob:9711055997

Roll up Contact on Account

trigger updateContactCountonAccount on Contact (after insert,after Delete) { Set<ID> setofAccId = new Set<Id>(); Map<Id,List<Contact>> MapAccIDTOListOfCont = new Map<Id,List<Contact>>(); Map<ID,Account> MapIDToAccount = new Map<Id,Account>(); if(Trigger.isAfter && Trigger.isInsert) { for(Contact ObjCOn: trigger.new) { if(ObjCOn.AccountId !=null) { setofAccId.add(ObjCOn.AccountId); } } } if(Trigger.isAfter && Trigger.isDelete) { for(Contact ObjCOn: trigger.old) { if(ObjCOn.AccountId !=null) { setofAccId.add(ObjCOn.AccountId); } } } for(Account objAcc:[Select Id from Account where ID IN:setofAccId]) { MapIDToAccount.put(objAcc.ID,objAcc); } for(Contact objCon:[Select id , Name,AccountId from Contact where Accou

Remove "-None-" value from Visualforce Page in Standard and Custom Pick List Values

Solution  There are Two Solution to  Remove "-None-" value from salesforce standard and custom Selected Picklist field. 1) Do "Required" In Visualforce Page means Required= "true" or On Pagelayout Required CheckBox true. 2) Using Jquery <apex:page standardController="Case">     <apex:form>         <script type='text/javascript' src= '//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'>         </script>         <script language="javascript">             $(function() {                         $('select.RemoveNoneValue option[value=]').remove();                    });         </script>             <apex:inputField styleClass="RemoveNoneValue" value="{!Case.Status__c}"/>     </apex:form> </apex:page> Thanks Sumit Shukla sumitshukla.mca@gmail.com

Number to Word Apex Code

Public Class NumberToWordClass {   public String ru{get;set;}   public Void NumberToWord(Integer no)     {                        ru='';         String[] word = new List<String>         {            '',' ONE ',' TWO ',' THREE ',' FOUR ',' FIVE ',' SIX ',' SEVEN ',' EIGHT ',' NINE ',' TEN ',           ' ELEVEN ',' TWELVE ',' THIRTEEN ',' FOURTEEN ',' FIFTEEN ',' SIXTEEN ',' SEVENTEEN ',' EIGHTEEN ',' NINETEEN '         };         String[] tens = new List<String>         {         '','','TWENTY','THIRTY','FORTY','FIFTY','SIXTY','SEVENTY','EIGHTY','NINETY'         };           Integer n1,n2;           n1=math.mod(no,100);           if(n1>0)           {               if(n1<=19)               {          

Fetch All Account in SOQL without any Contacts.

Fetch All Account in SOQL without any Contacts. List<Account> lst=[SELECT Id                     from Account where ID NOT IN                    (Select AccountID from Contact) limit 1]; system.debug('lst****'+lst);

Get Max Value from Decimal List

List<Decimal> lstofDecimalValues = new List<Decimal>(); lstofDecimalValues.add(55.0); lstofDecimalValues.add(75.5); lstofDecimalValues.add(99.3); Decimal maxvalue = lstofDecimalValues[1];  system.debug('maxvalue***'+maxvalue);         For (integer i =0;i<lstofDecimalValues.size();i++)         {                          if( lstofDecimalValues[i] > maxvalue)                 maxvalue = lstofDecimalValues[i];  system.debug('maxvaluellll'+maxvalue);                     }     system.debug('the max value is'+maxvalue);

Send Birthday Email to Contacts Using Apex Code

// This is Class for Sending the Birthday Email with using Custom Template // Schedule this class weekly every morning  public  class SendBirthdayWishesEmail {          Public void sendBirthdayMail()     {           //Get date and Month from Today Date          Date thisDate = system.Today();         Integer SysDay = thisDate.Day(); // Get Day from 1 to 31         Integer SysMonth = thisDate.month(); //get Month from 1 to 12         String SysDayAndSysMont = SysDay +'/'+SysMonth; // get Day and Month                               Map<string,EmailTemplate> mapNameToEmailTemplate = new Map<string,EmailTemplate>();        // OrgWideEmailAddress replyEmail = [SELECT ID, DisplayName FROM OrgWideEmailAddress WHERE Address =: 'sumitshukla.mca@gmail.com'];                  for(EmailTemplate emailTemp : [Select id ,subject,body,DeveloperName,HtmlValue  from EmailTemplate where DeveloperName = 'Email Template Name']) // Firstly you need to c

How to use Comparable Interface in Salesforce

Image
The Comparable interface use for sorting : Lists that contain non-primitive data types, that is, Lists of user-defined types. In Apex you need to implement the Comparable interface with its compareTo method in your class. When a class implements the Comparable interface it has to implement a method called compareTo().  In this method the code has to be verified if two objects match or if one is larger than the other. Class Code global class  CamprableInterfaceExampleController {     public List<WrapperClass> WrapperList {get;set;}        public CamprableInterfaceExampleController () {         WrapperList = new List<WrapperClass>();         WrapperClass s1 = new WrapperClass('Sumit', 22);         WrapperList.add(s1);                  WrapperClass s2 = new WrapperClass ('Amit', 15);         WrapperList.add(s2);                  WrapperClass s3 = new WrapperClass ('Rahul', 55);         WrapperList.add(s3);                  Wrapp

Opne a VF page in Print Mode using a custom Button

Step 1: Create a VF page  <apex:page standardController="Contact" sidebar="false" showHeader="false">   <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" />      <style>         body{ font-size:14px;}                  .lblPrint{                      width:49%;             float:left;             border:1px solid White;             height:260px;         }     </style>          <apex:form > <div style='margin-left:5px;display:block;'> <div class='lblPrint'> <div class='MainPrint' style="padding-left:20px;padding-top:15px;" >                  <b> <apex:outputText value="{!UPPER(Contact.Salutation)}" style="font-size:14px;"/>&nbsp; <apex:outputText value="{!UPPER(Contact.Name)}" style="font-size:14px;"></apex:outpu

Send pdfContent using Trigger in salesforce

Requirement: I have VF page on render as pdf means it is PDF file. I want to send this pdf when in my object there is field "isSend" checkbox type is equal to true then send to users email ids ,   Send PDF using trigger using Web Service Class. you need to create two class and one trigger. And your VF Page Pdf class and page. Step 1: Create GETPDFContentController Class  /*   Before this you need to create a VFPage */ /** *   Created By### refernce No:20180555  :   Sumit Shukla *   Description :   This Apex class based on REST API which exposes POST method to send Email with * pdf content */ @RestResource(urlMapping='/sendPDFEmail/*') global class GETPDFContentController{      @HttpPost     global static void sendEmail(String EmailIds, String Subject, String body, string recordID) {     List<String> EmailIds = EmailIds.split(',');        PageReference ref = new PageReference('/apex/VFPageName?id='+recordID); // Firstly

Send Pdf Using Visualforce Email Template

Requirement:  Suppose you have a Object(Invoice__c) Record , There is  isSend Checkbox field , When  isSend = true then email goes to Admin user with Pdf Attachment. In Pdf there in Object Data and Related Child data in Table. Solution : For this you have two solution 1) Create a future call out class and write a trigger , In future class u can get pdfcontent 2) Using visualforce Email Template I m explaining Second one. We need to create Custom Component. Setup>> Develop>> Component>> New Component Name: GenrateInvoiceComponent and Create a Class  GenrateInvoiceComponentController Step 1: Create a Class GenrateInvoiceComponentController       GenrateInvoiceComponentController  Class Code Example public class GenrateInvoiceComponentController {     public string InvoiceID{get;set;} // this invoice will come from Url Public List<InvoiceLineItem> lstofChildRecortd{get;set;}        public string GenrateInvoiceComponentController    

Copy Billing Address to Shipping Address on VF Page Using JavaScript

Image
Class Code public class CopyAddressFromBillToShip{     public String BCountry { get; set; }     public String BZip { get; set; }     public String BState { get; set; }     public String BCity { get; set; }     public String BStreet { get; set; }     public String SCountry { get; set; }     public string SZip { get; set; }     public String SState { get; set; }     public String SCity { get; set; }     public String SStreet { get; set; } } Page Code <apex:page controller="CopyAddressFromBillToShip" >    <apex:form id="myform">     <script type="text/javascript">         function addressCopy(bstreet1, bcity1, bstate1, bPostalCode1, bcountry1, sstreet1, scity1, sstate1, SPostalCode1, scountry1) {     document.getElementById(sstreet1).value = document.getElementById(bstreet1).value;     document.getElementById(scity1).value = document.getElementById(bcity1).value;   document.getElementById(sstate1).value = document.