View

Friday, June 9, 2023

10 Features every Salesforce Professional should know (Continue...)

 


 



Admins/Devs/Consultants are a key part of any business that has a Salesforce implementation, they keep things ticking over as well as expanding Salesforce to include new departments and features.  Being a well-rounded Admin that understands all of Salesforce’s features is imperative and definitely key if you would like to get certified. One of the biggest benefits I see to knowing as many features as possible in Salesforce is that you will use more standard functionality that already exists, rather than going down the custom/code route.  This guide will highlight some areas that every Salesforce Admin should be able to implement and use, but if you can’t, don’t fear! I’m going to include links to the relevant trailhead modules and other resources to scrub up on your knowledge. Then we can just keep the secret between you and me before anyone finds out.

Custom Objects, Fields & Relationships :

In essence, Salesforce is simply a database with a bunch of related tables, columns and rows. Obviously it is a lot more than this but it is essential to learn the basics first. As well as the standard objects and fields that come with your Sales or Service cloud product, you can customize Salesforce with your own. Understanding the different types of relationships that link objects together, the different types of fields that can be used and the implications of using these is a foundation learning step.
The  Data Modeling trailhead module that will teach you all of this goes through 4 modules; Understanding Custom & Standard Objects, Creating Custom Objects & Fields, Creating Object Relationships & Working with Schema Builder.

 

Security Model :

The Salesforce security model is a bit of a beast to tame, but it interacts with everything you do in Salesforce. The security model encompasses features like profiles, roles, permissions sets, sharing settings, field level security, object permissions and the list goes on. Knowing each of these inside out is key to giving your user base the best user experience and keeping your data safe.
The Trailhead module called 1Data Security takes you through a systematic approach to look at how access to controlled to different aspects including, your overall organization, objects, fields, records and more.

 

User Management :

Being a Administrator means one of your most important responsibilities is making sure that all users can access every part of Salesforce they need to do their job. As well as roles & profiles to control what the User can do and see, you have a lot of user related permissions.
In this User Management trail, you will learn about how to control what the users can access and also how to add new users.

 





Page Layouts & Record Types :

A natural precursor from learning about fields and the security model is page layouts & record types. These two features are directly linked but have very different applications about when and how to use them. One of the best things you can learn about these two features is when one might suit better than the other.
The  App Customization Trailhead module will not only provide you with the tools to modify a page layout but also how to customize compact layouts on mobile devices as well as customizing actions. Record types are not yet featured in a Trailhead module but Salesforce has a fantastic cheat sheet to scrub up on your knowledge.

 

Reports & Dashboards :

f you are just getting to grips with Salesforce or are making the transition from Salesforce power user to #AwesomeAdmin then there’s a good chance you have had a lot of interaction with Reports & Dashboards. However, if you haven’t dove into this world yet then this is a good chance to do some exploring. Reports & Dashboards are the main end goal for some executive management teams and therefore are critical to the business.
The appropriately named Reports & Dashboards trail is fantastic to get started. There is A LOT of information here. This is mainly due to the fact that there is just so much to learn, from building reports, to using report formats and transferring this into pretty little dashboards!

 

Workflows & Process Builder :

Once you’ve got the basics of the Salesforce CRM nailed down, it’s time to go onto automation. Workflow rules and the process builder are great ways of using clicks not code, to automate complex business processes. Workflows can be triggered by an event like Opportunity Stage = Closed Won and can have various actions like field updates, send email and create task. The process builder is the “new age” of workflows and has more actions like, post to chatter and create record.
The Trailhead module called Process Automation takes you through a detailed course of which process automation tool to use and why, it also goes through step by step tutorials.





 

10 Features every Salesforce Professional should know

 


 



Admins/Devs/Consultants are a key part of any business that has a Salesforce implementation, they keep things ticking over as well as expanding Salesforce to include new departments and features.  Being a well rounded Admin that understands all of Salesforce’ features is imperative and definitely key if you would like to get certified. One of the biggest benefits I see to knowing as many features as possible in Salesforce, is that you will use more standard functionality that already exists, rather than going down the custom/code route.  This guide is going to highlight some areas that every Salesforce Admin should be able to implement and use, but if you can’t, don’t fear! I’m going to include links to the relevant trailhead modules and other resources to scrub up on your knowledge. Then we can just keep the secret between you and me before anyone finds out.

Custom Objects, Fields & Relationships :

In essence, Salesforce is simply a database with a bunch of related tables, columns and rows. Obviously it is a lot more than this but it is essential to learn the basics first. As well as the standard objects and fields that come with your Sales or Service cloud product, you can customize Salesforce with your own. Understanding the different types of relationships that link objects together, the different types of fields that can be used and the implications of using these is a foundation learning step.
The  Data Modeling trailhead module that will teach you all of this goes through 4 modules; Understanding Custom & Standard Objects, Creating Custom Objects & Fields, Creating Object Relationships & Working with Schema Builder.

 

Security Model :

The Salesforce security model is a bit of a beast to tame, but it interacts with everything you do in Salesforce. The security model encompasses features like profiles, roles, permissions sets, sharing settings, field level security, object permissions and the list goes on. Knowing each of these inside out is key to giving your user base the best user experience and keeping your data safe.
The Trailhead module called 1Data Security takes you through a systematic approach to look at how access to controlled to different aspects including, your overall organization, objects, fields, records and more.

 

User Management :

Being a Administrator means one of your most important responsibilities is making sure that all users can access every part of Salesforce they need to do their job. As well as roles & profiles to control what the User can do and see, you have a lot of user related permissions.
In this User Management trail, you will learn about how to control what the users can access and also how to add new users.

 





Page Layouts & Record Types :

A natural precursor from learning about fields and the security model is page layouts & record types. These two features are directly linked but have very different applications about when and how to use them. One of the best things you can learn about these two features is when one might suit better than the other.
The  App Customization Trailhead module will not only provide you with the tools to modify a page layout but also how to customize compact layouts on mobile devices as well as customizing actions. Record types are not yet featured in a Trailhead module but Salesforce has a fantastic cheat sheet to scrub up on your knowledge.

 

Reports & Dashboards :

f you are just getting to grips with Salesforce or are making the transition from Salesforce power user to #AwesomeAdmin then there’s a good chance you have had a lot of interaction with Reports & Dashboards. However, if you haven’t dove into this world yet then this is a good chance to do some exploring. Reports & Dashboards are the main end goal for some executive management teams and therefore are critical to the business.
The appropriately named Reports & Dashboards trail is fantastic to get started. There is A LOT of information here. This is mainly due to the fact that there is just so much to learn, from building reports, to using report formats and transferring this into pretty little dashboards!

 

Workflows & Process Builder :

Once you’ve got the basics of the Salesforce CRM nailed down, it’s time to go onto automation. Workflow rules and the process builder are great ways of using clicks not code, to automate complex business processes. Workflows can be triggered by an event like Opportunity Stage = Closed Won and can have various actions like field updates, send email and create task. The process builder is the “new age” of workflows and has more actions like, post to chatter and create record.
The Trailhead module called Process Automation takes you through a detailed course of which process automation tool to use and why, it also goes through step by step tutorials.





 

Wednesday, May 1, 2013

Video File on Setting of Company profile .................






Video File on Offline Integration.................




Apex Code : Pagging.............



Page Editor:
------------
<apex:page Controller="LeadCusControl" action="{!Search}" sidebar="false" >
<apex:form id="changeStatusForm">
        <apex:pageBlock id="pb1" >
        <apex:pageMessages />
        <table width="100%">
      <tr>
      <td align="left" ><apex:commandButton value="Prev"  action="{!Prev}" rendered="{!showprev}"  rerender="pb1"/></td>
       
          <td align="right"><apex:commandButton value="Next"  action="{!Next}" rendered="{!shownext}"  rerender="pb1"/></td>
      </tr>
      </table>
            <apex:pageBlockTable value="{!leads}" var="c" columns="7">
            <apex:column value="{!c.Name}"/>
            <apex:column value="{!c.Company}"/>
            <apex:column value="{!c.Title}"/>
            <apex:column headerValue="Recent Activity">
                  <apex:dataTable value="{!c.Tasks}" var="s" >
                      <apex:column value="{!s.subject}" style="border-bottom-color:transparent;" />
                  </apex:dataTable>
           </apex:column>
            <apex:column value="{!c.City}"/>
                        <apex:column headerValue="Action"  >
                        <a href="/00T/e?who_id={!c.id}&retURL=%2F{!c.id}">Next Activity </a>        
                        <a href="/{!c.id}/e?retURL=%2F{!c.id}" > / EditLead</a>
            </apex:column>
        </apex:pageBlockTable>
      <table width="100%">
      <tr>
      <td align="left" ><apex:commandButton value="Prev"  action="{!Prev}" rendered="{!showprev}"  rerender="pb1"/></td>
          <td align="Center"><b><apex:outputtext rendered="{!NOT(ISNULL(Leads))}"  value="{!LdList_Size}  records in Lead"/></b></td>
          <td align="right"><apex:commandButton value="Next"  action="{!Next}" rendered="{!shownext}"  rerender="pb1"/></td>
      </tr>
      </table>
</apex:pageBlock>    
</apex:form>
</apex:page>

Apex Class
------------------
public class LeadCusControl {
    List<Lead> LdList = new List<Lead>();
    List<Lead> LdList_Next = new List<Lead>();
    Integer next = 10, count = 10;
    boolean shownext, showprev;
   
    Public void Search()
    {
        try
        {
            LdList = [SELECT name,company,title,city,state,email,id, (SELECT subject FROM tasks order by lastmodifieddate desc limit 1) FROM lead];
            if(LdList.size()>count)
            {
                for(Integer i=0; i<count; i++)
                LdList_Next.add(LdList[i]);
                shownext = true;
            }
            else
            LdList_Next = LdList;
        }catch(Exception e){system.debug('Exception :'+e);}
    }
    Public Integer GetLdList_Size()
    {
        return LdList.size();
    }
     Public List<Lead> GetLeads()
    {
        return LdList_Next;
    }
    Public void Next()
    {
        try
        {
            showprev = true;
            LdList_Next.clear();
            Integer limit1 = 0;
   
            if(next+count < LdList.size())
                limit1 = next+count;
            else
            {
                limit1 = LdList.size();
                shownext = false;
            }
               
            for(Integer i=next; i<limit1; i++)
            LdList_Next.add(LdList[i]);
   
            Next+=count;
        }catch(Exception e){system.debug('Exception :'+e);}
    }
    Public void Prev()
    {
        try
        {
            shownext = true;
            LdList_Next.clear();
            Integer limit1 = 0;      
            if(next-(count+count) > 0)
                limit1 = next-count;
            else
            {
                limit1 = next-count;
                showprev = false;
            }
   
            for(Integer i=next-(count+count); i<limit1; i++)  
            LdList_Next.add(LdList[i]);
            Next-=count;
        }catch(Exception e){system.debug('Exception :'+e);}              
    }
   
    Public boolean getshownext(){return shownext;}
   
    Public boolean getshowprev(){return showprev;}
}

Apex Code : Sample Class With Trigger .............



Trigger:
--------
trigger Attendance on Session__c (after insert)
{
   Session__c[] s = trigger.new;
   Attendance.attendanceupdate(s);
}


Class:
----------
public class Attendance
    {
      public static void attendanceupdate(Session__c[] session)
     {
        //for(Session__c s:[SELECT Name,Course__c,Session_Date__c from Session__c ])
        for(Session__c s:session)
        {
        //system.debug('session:'+s);
         // for(Enrollment__c e : [SELECT Participant__c from Enrollment__c where Enrollment__c.Course__c = :s.Course__c])
          for(Enrollment__c e : [SELECT Participant__c from Enrollment__c where Enrollment__c.Course__c = :s.Course__c AND Enrollment__c.Preparable_Season__c =:s.Season__c AND Enrollment__c.Enrollment_Status__c= 'In Progress'])

          {
            String inp = 'In progress';
             system.debug('enr:'+e);
            Attendance__c att = new Attendance__c(Participant__c = e.Participant__c, Present__c=false,Absent__c=false,Excuse_Details__c='',Attendance_Date__c=s.Session_Date__c,Session__c=s.id);
            upsert att;    
          }
        }
     }
    }

Apex Code : Data Table.............



Page:
=====
<apex:page controller="dataTableCon" id="thePage">

        <apex:dataTable border="1" bgcolor="Red" align="Center"  value="{!accounts}" var="account" id="theTable" rowClasses="odd,even"

                        styleClass="tableClass">

                <apex:facet name="caption" >table caption</apex:facet>

                <apex:facet name="header">table header</apex:facet>

                <apex:facet name="footer">table footer</apex:facet>

                <apex:column >

                        <apex:facet name="header">Name</apex:facet>

                        <apex:facet name="footer">column footer</apex:facet>

                        <apex:outputText value="{!account.name}"/>

                </apex:column>

                <apex:column >

                        <apex:facet name="header">Owner</apex:facet>

                        <apex:facet name="footer">column footer</apex:facet>

                        <apex:outputText value="{!account.owner.name}"/>

                </apex:column>
                 <apex:column >

                        <apex:facet name="header">Billing Country</apex:facet>

                        <apex:facet name="footer">column footer</apex:facet>

                        <apex:outputText value="{!account.BillingCountry}"/>

                </apex:column>

        </apex:dataTable>

</apex:page>


Controller:
----------
public class dataTableCon
{                    
        List<Account> accounts;
        public List<Account> getAccounts()
        {
                if(accounts == null) accounts = [Select a.BillingCountry, a.Id, a.Name, a.OwnerId, a.Owner.Name, a.Phone from Account a];
                return accounts;
        }
}

Apex Code : Converting one object to Another.............



trigger Helloworld on Lead (before insert)
{
  for(Lead l: Trigger.New)
  {
    l.Hello__c = 'Surendharan';
    Contact  c = new Contact(LastName= l.LastName);
    insert c;
    if(l.College__c !=null)
    {
      Account a = new Account(Name= l.College__c);
    insert a;
    }
  }
}



01590000000FYtQ


Security Token:  

User Name: sampath@offline.com
Security Token: wEToynf7jsZsxbmWjrPypcoWi



User Name: an.nagalakshmanan@gmail.com
Security Token: 9zMv5Ni7EdShLDQLF9hxO7xA
Password: navavi28

Apex Cod e : Copy Quote Working .............



trigger CopyingQuoteValues on Quote (before update)
{
    //Cloning the Quote: START//
   

    for(Quote qt: Trigger.new)
    {
        //Check for Amendment Type "Product"
        if(qt.Is_Locked__c && qt.Amendment_Type__c != null && qt.Amendment_Type__c == 'Product' && qt.Amended_Lease__c != null)
        {
            mapQuoteProduct.put(qt.Id, qt);
            mapOpptyProduct.put(qt.Id, qt.OpportunityId);
            mapOrgProduct.put(qt.Id, qt.Amended_Lease__c);
   
        }
       
        //Check for Amendment Type "Lessee"    
        if(qt.Is_Locked__c && qt.Amendment_Type__c != null && qt.Amendment_Type__c == 'Lessee' && qt.Amended_Lease__c != null)
        {
            mapQuoteLessee.put(qt.Id, qt);
            mapOpptyLessee.put(qt.Id, qt.OpportunityId);
            mapOrgLessee.put(qt.Id, qt.Amended_Lease__c);
           
        }
       
        //Check for Amendment Type "Production"    
        if(qt.Is_Locked__c && qt.Amendment_Type__c != null && qt.Amendment_Type__c == 'Production' && qt.Amended_Lease__c != null)
        {
            mapQuoteProduction.put(qt.Id, qt);
            mapOpptyProduction.put(qt.Id, qt.OpportunityId);
            mapOrgProduction.put(qt.Id, qt.Amended_Lease__c);
             
        }      
    }

    Map<id, Quote> mAmdQ = new Map<Id, Quote>([SELECT id,
                                                      (SELECT id, Item__c, Quantity__c, Quote__c, Unit_Price__c, CurrencyIsoCode FROM Quote_Lines__r),
                                                      (SELECT Id, Name, CurrencyIsoCode, Quote__c, Annual_Lease_Payment__c, Annual_Lease_Payments_Year__c, Annual_SystemProduction_Guarantee_Year__c, Approximate_Price_per_kWh__c, Base_Monthy_Payment__c, Est_Monthly_Paymt_w_o_formula__c, Est_Mthly_Paymt_includingTax_w_auto_ACH__c, Est_Mthly_Paymt_with_formula__c, Estimated_Monthly_Payment_inclusive_of_T__c, Estimated_Tax_on_Monthly_Payment__c, Guarantee_Year__c, Guaranteed_Range_of_Annual_Production__c, Lease_Payments_Year__c, Monthly_Payments_and_with_automatic_ACH__c, PeGu_Estimate__c, Rate_Per_KWH__c, Record_Count__c, Remaining_Lease_Period__c, Remaining_Lease_Value__c, RoundOff_Base_Monthly_Payment__c, RoundOff_Rate_Per_KWH__c, RoundOff_Remaining_Lease_Value__c, System_Production_Annual_Production__c, Temp_Monthly_Lease_Payments__c, X105_of_S_P_A_P__c, X95_of_S_P_A_P__c, Final_Base_Monthly_Payment__c, Final_Estimated_Tax_on_Monthly__c, Final_Estimated_Monthly_W_Tax_No_ACH__c, Final_Estimated_Monthly_W_Tax_W_ACH__c, Final_Total_Yearly_Page_2__c, Final_Total_Yearly_Page_4__c, Final_Estimated_Monthly_W_Tax_No_ACH_p2__c, Tax_Rate__c, Final_Tax_Rate__c FROM Lease_Progress__r)
                                               FROM Quote
                                               WHERE id IN: (!mapQuoteProduct.isEmpty() ? mapQuoteProduct.keySet() : new Set<id>()) OR
                                                     id IN: (!mapQuoteLessee.isEmpty() ? mapQuoteLessee.keySet() : new Set<id>()) OR
                                                     id IN: (!mapQuoteProduction.isEmpty() ? mapQuoteProduction.keySet() : new Set<id>())]);
   

   
    List<Quote> lstArchievedQuote = new List<Quote>();
    List<Quote> lstCopyAmeInfoQuote = new List<Quote>();
   
    List<Quote_Line__c> lstQLDelete = new List<Quote_Line__c>();
    List<Quote_Line__c> lstQL = new List<Quote_Line__c>();
    List<Lease_Schedule__c> lstLP = new List<Lease_Schedule__c>();
   
       
    //*********Product***********
    if(!mapOrgProduct.isEmpty())
    {
        for(Quote qotsProduct: [SELECT id, name, opportunityId,
                                Module_Oracle_Item_Number__c, Quote_Inverter_Values__c,Module__c,
                                Module_Brand__c, Module_Quantity__c,
                                Module_Type__c, Monitoring_System_Model__c,
                                Monitoring_System_Option__c, Monitoring_System_Quantity__c,
                                Mounting_Option__c, Construction__c,
                                Dealer_Fees__c, Interconnect__c,
                                Inverter_Brand__c, Origination__c,
                                Inverter_Brand_2__c, Inverter_Brand_3__c,
                                Inverter_Brand_4__c, Inverter_Model__c,
                                Inverter_Model_2__c, Inverter_Model_3__c,
                                Inverter_Model_4__c, System_Size__c,
                                (SELECT id, Item__c, Quantity__c, Quote__c, Unit_Price__c, CurrencyIsoCode FROM Quote_Lines__r)                  
                                FROM Quote
                                WHERE id IN: mapOrgProduct.values()])
        {
                               
            for(Id amdProductId : mapOrgProduct.keySet())
            {
                if(mapOrgProduct.get(amdProductId) == qotsProduct.Id)
                {
                    Quote q = qotsProduct.clone(false, true, true, true);
                    q.OpportunityId = qotsProduct.OpportunityId;
                    lstArchievedQuote.add(q);
                   
                    qotsProduct.Module_Oracle_Item_Number__c = mapQuoteProduct.get(amdProductId).Module_Oracle_Item_Number__c;
                    qotsProduct.Module_Quantity__c = mapQuoteProduct.get(amdProductId).Module_Quantity__c;
                    qotsProduct.Quote_Inverter_Values__c = mapQuoteProduct.get(amdProductId).Quote_Inverter_Values__c;
                    qotsProduct.Module__c = mapQuoteProduct.get(amdProductId).Module__c;
                    qotsProduct.Module_Brand__c = mapQuoteProduct.get(amdProductId).Module_Brand__c;
                    qotsProduct.Module_Type__c = mapQuoteProduct.get(amdProductId).Module_Type__c;
                    qotsProduct.Monitoring_System_Model__c = mapQuoteProduct.get(amdProductId).Monitoring_System_Model__c;
                    qotsProduct.Monitoring_System_Option__c = mapQuoteProduct.get(amdProductId).Monitoring_System_Option__c;
                    qotsProduct.Monitoring_System_Quantity__c = mapQuoteProduct.get(amdProductId).Monitoring_System_Quantity__c;
                    qotsProduct.Mounting_Option__c = mapQuoteProduct.get(amdProductId).Mounting_Option__c;
                    qotsProduct.Inverter_Brand__c = mapQuoteProduct.get(amdProductId).Inverter_Brand__c;
                    qotsProduct.Inverter_Brand_2__c = mapQuoteProduct.get(amdProductId).Inverter_Brand_2__c;
                    qotsProduct.Inverter_Brand_3__c = mapQuoteProduct.get(amdProductId).Inverter_Brand_3__c;
                    qotsProduct.Inverter_Brand_4__c = mapQuoteProduct.get(amdProductId).Inverter_Brand_4__c;
                    qotsProduct.Inverter_Model__c = mapQuoteProduct.get(amdProductId).Inverter_Model__c;
                    qotsProduct.Inverter_Model_2__c = mapQuoteProduct.get(amdProductId).Inverter_Model_2__c;
                    qotsProduct.Inverter_Model_3__c = mapQuoteProduct.get(amdProductId).Inverter_Model_3__c;
                    qotsProduct.Inverter_Model_4__c = mapQuoteProduct.get(amdProductId).Inverter_Model_4__c;
                    qotsProduct.Inverter_Quantity__c = mapQuoteProduct.get(amdProductId).Inverter_Quantity__c;
                    qotsProduct.Inverter_Quantity_2__c = mapQuoteProduct.get(amdProductId).Inverter_Quantity_2__c;
                    qotsProduct.Inverter_Quantity_3__c = mapQuoteProduct.get(amdProductId).Inverter_Quantity_3__c;
                    qotsProduct.Inverter_Quantity_4__c = mapQuoteProduct.get(amdProductId).Inverter_Quantity_4__c;
                    qotsProduct.System_Cost__c = mapQuoteProduct.get(amdProductId).System_Cost__c;
                    qotsProduct.Dealer_Fees__c = mapQuoteProduct.get(amdProductId).Dealer_Fees__c;
                    qotsProduct.Origination__c = mapQuoteProduct.get(amdProductId).Origination__c;
                    qotsProduct.Construction__c = mapQuoteProduct.get(amdProductId).Construction__c;
                    qotsProduct.Interconnect__c = mapQuoteProduct.get(amdProductId).Interconnect__c;  
                   
                    lstCopyAmeInfoQuote.add(qotsProduct);

                    List<Quote_Line__c> tempQL = qotsProduct.Quote_Lines__r;
                 
                    if(!tempQL.isEmpty())
                    {
                        lstQLDelete.addAll(tempQL);
                        if(!mAmdQ.isEmpty() && mAmdQ.containsKey(amdProductId))
                        {
                            List<Quote_Line__c> tempAmdQL = mAmdQ.get(amdProductId).Quote_Lines__r;
                            if(!tempAmdQL.isEmpty())
                            {
                                for(Quote_Line__c ql: tempAmdQL)
                                {
                                    lstQL.add(new Quote_Line__c (Quote__c = qotsProduct.Id,
                                                                 Item__c = ql.Item__c,
                                                                 Quantity__c = ql.Quantity__c,
                                                                 Unit_Price__c = ql.Unit_Price__c,
                                                                 CurrencyIsoCode = ql.CurrencyIsoCode));
                                }
                            }
                        }
                       
                     }                  
                }//End If
            }//End For
        }//End For
    }
    //***** END PRODUCT *****//
   
    //******LESSEE Info****
    if(!mapOrgLessee.isEmpty())
    {
        for(Quote qotsLessee: [SELECT id, name, opportunityId,
                                 Module_Oracle_Item_Number__c, Quote_Inverter_Values__c,Module__c,
                                 Module_Brand__c, Module_Quantity__c,
                                 Module_Type__c, Monitoring_System_Model__c,
                                 Monitoring_System_Option__c, Monitoring_System_Quantity__c,
                                 Mounting_Option__c, Construction__c,
                                 Dealer_Fees__c, Interconnect__c,
                                 Inverter_Brand__c, Inverter_Brand_2__c,
                                 Inverter_Brand_3__c, Inverter_Brand_4__c,
                                 Inverter_Model__c, Inverter_Model_2__c,
                                 Inverter_Model_3__c, Inverter_Model_4__c,
                                 Origination__c, System_Size__c
                                 FROM Quote
                                 WHERE id IN: mapOrgLessee.values()])
        {
                               
            for(Id amdLesseeId : mapOrgLessee.keySet())
            {
                if(mapOrgLessee.get(amdLesseeId) == qotsLessee.Id)
                {
                    Quote q = qotsLessee.clone(false, true, true, true);
                    q.OpportunityId = qotsLessee.OpportunityId;
                    lstArchievedQuote.add(q);
                   
                    qotsLessee.Temp_Contact_1__c = mapQuoteLessee.get(amdLesseeId).Temp_Contact_1__c;
                    qotsLessee.Temp_Contact_2__c = mapQuoteLessee.get(amdLesseeId).Temp_Contact_2__c ;
                    qotsLessee.Lessee__c = mapQuoteLessee.get(amdLesseeId).Lessee__c;
                                       lstCopyAmeInfoQuote.add(qotsLessee);
                }
            }
        }
    }
    //***** END LESSEE *****//      
       
    //**************Production*************
    if(!mapOrgProduction.isEmpty())
    {
        for(Quote qotsProduction: [SELECT id, name, opportunityId,
                                 Module_Oracle_Item_Number__c, Quote_Inverter_Values__c,Module__c, Module_Brand__c,
                                 Module_Quantity__c, Module_Type__c, Monitoring_System_Model__c, Monitoring_System_Option__c,
                                 Monitoring_System_Quantity__c, Mounting_Option__c, Construction__c, Dealer_Fees__c, Interconnect__c,
                                 Inverter_Brand__c, Inverter_Brand_2__c, Inverter_Brand_3__c, Inverter_Brand_4__c,
                                 Inverter_Model__c, Inverter_Model_2__c, Inverter_Model_3__c, Inverter_Model_4__c, Origination__c, System_Size__c,
                                 (SELECT id, Item__c, Quantity__c, Quote__c, Unit_Price__c, CurrencyIsoCode FROM Quote_Lines__r),
                                 (SELECT Id, Name, CurrencyIsoCode, Quote__c, Annual_Lease_Payment__c, Annual_Lease_Payments_Year__c, Annual_SystemProduction_Guarantee_Year__c, Approximate_Price_per_kWh__c, Base_Monthy_Payment__c, Est_Monthly_Paymt_w_o_formula__c, Est_Mthly_Paymt_includingTax_w_auto_ACH__c, Est_Mthly_Paymt_with_formula__c, Estimated_Monthly_Payment_inclusive_of_T__c, Estimated_Tax_on_Monthly_Payment__c, Guarantee_Year__c, Guaranteed_Range_of_Annual_Production__c, Lease_Payments_Year__c, Monthly_Payments_and_with_automatic_ACH__c, PeGu_Estimate__c, Rate_Per_KWH__c, Record_Count__c, Remaining_Lease_Period__c, Remaining_Lease_Value__c, RoundOff_Base_Monthly_Payment__c, RoundOff_Rate_Per_KWH__c, RoundOff_Remaining_Lease_Value__c, System_Production_Annual_Production__c, Temp_Monthly_Lease_Payments__c, X105_of_S_P_A_P__c, X95_of_S_P_A_P__c, Final_Base_Monthly_Payment__c, Final_Estimated_Tax_on_Monthly__c, Final_Estimated_Monthly_W_Tax_No_ACH__c, Final_Estimated_Monthly_W_Tax_W_ACH__c, Final_Total_Yearly_Page_2__c, Final_Total_Yearly_Page_4__c, Final_Estimated_Monthly_W_Tax_No_ACH_p2__c, Tax_Rate__c, Final_Tax_Rate__c FROM Lease_Progress__r)
                                 FROM Quote
                                 WHERE id IN: mapOrgProduction.values()])
        {
                               
            for(Id amdProductionId : mapOrgProduction.keySet())
            {
                if(mapOrgProduction.get(amdProductionId) == qotsProduction.Id)
                {
                    Quote q = qotsProduction.clone(false, true, true, true);
                    q.OpportunityId = qotsProduction.OpportunityId;
                    lstArchievedQuote.add(q);
 
                }
               
     
                List<Lease_Schedule__c> tempLP = qotsProduction.Lease_Progress__r;
                //Prashant: 0309: Start              
                List<Lease_Schedule__c> tempAmeLP = mAmdQ.get(amdProductionId).Lease_Progress__r;
                if(!tempLP.isEmpty() && !tempAmeLP.isEmpty())
                {
                    for(Lease_Schedule__c ameLS: tempAmeLP)
                    {

                        for(Lease_Schedule__c orgLS: tempLP)
                        {
                            if(ameLS.Temp_Monthly_Lease_Payments__c== orgLS.Temp_Monthly_Lease_Payments__c)
                            {
                            orgLS.PeGu_Estimate__c = ameLS.PeGu_Estimate__c;
                            orgLS.Guaranteed_Range_of_Annual_Production__c = ameLS.Guaranteed_Range_of_Annual_Production__c;
                            orgLS.System_Production_Annual_Production__c = ameLS.System_Production_Annual_Production__c;
                             lstLP.add(orgLS);                              
                            }
                        }
                    }
                }
            }
        }
    }
   
    if(!lstArchievedQuote.isEmpty())
        insert lstArchievedQuote;

    if(!lstCopyAmeInfoQuote.isEmpty())
        update lstCopyAmeInfoQuote;
   
    if(!lstQL.isEmpty())
        insert lstQL;
   
    if(!lstLP.isEmpty())
        update lstLP;

    if(!lstQLDelete.isEmpty())
        delete lstQLDelete;

}//End Trigger CloneQuote

Apex Cod e : Attendance.............


public class attendance
{

 public static void Test(Session__c [] session)
{
   List<Attendance__c> att = new List<Attendance__c>();
   Date obj = Date.today();
   for (Session__c s:session)
   {
       for(Enrollment__c e : [Select Contact__c From Enrollment__c where Program__c =:s.Program__c])
       {
          try
          {
                att.add(new Attendance__c(Present__c =false, Excused_Absence__c =false, Excuse_Details__c='',date__c = s.Session_Date__c, Youth__c = e.Contact__c, Session__c = s.id));
                upsert att;
          }
          catch(DmlException d)
           {
                d.getMessage();
           }
       }
     
   
 
   }
}
}

Apex Code : Add and Delete accounts....................



Add And Delete accounts using page::

page:
----------

<apex:page controller="DataTableEditRemoveController" sidebar="false" showHeader="false">
<apex:form id="form" >
    <apex:pageBlock title="Accounts">
        <apex:pageBlockTable value="{!accs}" var="row">
         <apex:column >
           <apex:outputLink value="https://ap1.salesforce.com/003/e?retURL=%2F003%2Fo" style="font-weight:bold">Add</apex:outputLink>&nbsp;|&nbsp;
           <apex:outputLink title="" value="/{!row.id}/e?retURL=/apex/{!$CurrentPage.Name}" style="font-weight:bold">Edit</apex:outputLink>&nbsp;|&nbsp;
           <a href="javascript:if (window.confirm('Are you sure?')) DeleteAccount('{!row.Id}');" style="font-weight:bold">Del</a>
         </apex:column>
         <apex:column value="{!row.Name}"/>
         <apex:column value="{!row.BillingStreet}"/>
         <apex:column value="{!row.BillingCity}"/>
         <apex:column value="{!row.BillingPostalCode}"/>
         <apex:column value="{!row.BillingCountry}"/>
  </apex:pageBlockTable>
</apex:pageBlock>
<apex:actionFunction action="{!DeleteAccount}" name="DeleteAccount" reRender="form" >
<apex:param name="accountid" value="" assignTo="{!SelectedAccountId}"/>
</apex:actionFunction>
</apex:form>
</apex:page>


controller::
-----------------

public class DataTableEditRemoveController {

   public List<Account> accs { get; set; }
 
   //used to get a hold of the account record selected for deletion
   public string SelectedAccountId { get; set; }
 
   public DataTableEditRemoveController() {
       //load account data into our DataTable
       LoadData();
   }
 
   private void LoadData() {
       accs = [Select id, name, BillingStreet, BillingCity, BillingPostalCode, BillingCountry from Account limit 20];
   }
 
   public void DeleteAccount()
   {
      // if for any reason we are missing the reference
      if (SelectedAccountId == null) {
     
         return;
      }
   
      // find the account record within the collection
      Account tobeDeleted = null;
      for(Account a : accs)
       if (a.Id == SelectedAccountId) {
          tobeDeleted = a;
          break;
       }
     
      //if account record found delete it
      if (tobeDeleted != null) {
       Delete tobeDeleted;
      }
   
      //refresh the data
      LoadData();
   }  
 
 
}

Apex Coding on Phone Number Validation Rule.....



IF( ISBLANK(Phone) , false , NOT(REGEX(Phone, "\\D*?(\\d\\D*?){10}")) )

Apex Coding on Updating Records Using VisualForce Page with Controller.....



Page:
----
<apex:page StandardController="Event" extensions="eventcontroller">
  <script>
    function confirmCancel()
    {
        var isCancel = confirm("Are you sure you wish to cancel?");
        if (isCancel) return true;
        return false;
    }
   var newWin=null;
   function fillFields(oSel)
    {
         var oForm = oSel.parent;
         //alert(oSel.options[oSel.selectedIndex].value);
         switch (oSel.options[oSel.selectedIndex].value)
         {
            case "Yes":
                // document.getElementById('j_id0:parent:j_id3:choice').disabled=true;
                 document.getElementById('test1').style.display='none';
                 document.getElementById('j_id0:parent:j_id30:choice').style.display='none';
                 break;
            case "No":
                 document.getElementById('test1').style.display='block';
                 document.getElementById('test2').style.display='block';
                document.getElementById('j_id0:parent:j_id30:choice').style.display='block';
                 break;
               
                 default :
                 //document.getElementById('j_id0:parent:j_id30:choice').disabled=true;
                 document.getElementById('test1').style.display='none';
                 document.getElementById('j_id0:parent:j_id30:choice').style.display='none';
                }
    }
       
   
    </script>
  <apex:sectionHeader title="Complete Meeting Edit" subtitle="Complete Meeting"/>
 <apex:form id="parent">
 <apex:pageMessages > </apex:pageMessages>
    <apex:pageBlock title="Complete Meeting Edit" mode="edit">
  <apex:pageBlockButtons >
     <apex:commandButton action="{!save1}" value="Save"/>
     <apex:commandButton action="{!cancel}" value="Cancel" onclick="return confirmCancel()" immediate="true"/>
  </apex:pageBlockButtons>
 
  <table  style="padding-left:200px">
       <tr>
          <td>&nbsp;
          </td>
      </tr>
       <tr>
           <td align="right"><b>Meeting is Valid:</b>
           </td>
           <td align="left">
               <apex:inputField value="{!events.Attend__c}" required="true" onchange="fillFields(this)"/>
           </td>
       </tr>
       <tr>
           <td align="right"><p id="test1" style="display:none" ><b>Reason for Failure:</b></P>
           </td>
           <td  id="test2" align="left">
                 <apex:inputField value="{!events.Reason__c}" required="true" id="choice" style="display:none"/>
           </td>
       </tr>        
  </table>
 </apex:pageBlock>
  </apex:form>
</apex:page>


Controller:
============
public class eventcontroller
{
 
    public eventcontroller(ApexPages.StandardController controller)
    {
    }  
   Event events;
   public Event getevents()
   {
        if(events== null)
            events = new Event();
        return events;
    }
    public PageReference save1()
    {
     
      Event e = new Event();
      String eventid= System.currentPageReference().getParameters().get('eid');
      system.debug('Event:'+eventid);
      e = [Select e.Attend__c, e.Id, e.Reason__c from Event e  where e.id=:eventid];
     
        system.debug('Event details:'+e);
        e.Attend__c=events.Attend__c;
        e.Reason__c=events.Reason__c;
        e.Meeting_Completed__c =true;
        update e;
        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'Record(s) have been Updated Successfully.Please Refresh Your Account Record to see the imported data'));
        PageReference redirecturl = new PageReference('https://ap1.salesforce.com/'+eventid);
        return redirecturl;
        //return null;
    }

}

Apex Coding on Mass Updating Records with a Custom List Controller .....



Class:
============
public class selectedSizeWorkaround {

    ApexPages.StandardSetController setCon;

    public selectedSizeWorkaround(ApexPages.StandardSetController controller) {
        setCon = controller;
    }

    public integer getMySelectedSize() {
        return setCon.getSelected().size();
    }
    public integer getMyRecordsSize() {
        return setCon.getRecords().size();
    }
}

========================
Page:
=====
<apex:page standardController="Opportunity"
    recordSetVar="opportunities"
    extensions="selectedSizeWorkaround"
    showHeader="false"
    id="muopp"
>
    <apex:form id="muform">
        <apex:pageMessage summary="Selected Collection Size: {!mySelectedSize}"
            severity="info"
            id="mupms"
        />
        <apex:pageMessage summary="Record Set Size: {!myRecordsSize}"
            severity="info"
            id="mupmr"
        />
        <apex:pageBlock title="Opportunity Mass-Update" mode="edit" id="mub1">
            <apex:pageMessages />
            <apex:pageBlockSection id="mus1">
                <apex:inputField value="{!opportunity.stagename}" id="stagename">
                    <apex:actionSupport event="onchange" rerender="muselectedlist"/>
                </apex:inputField>
            </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom" id="mubut">
                <apex:commandButton value="Save" action="{!save}" id="butsav"/>
                <apex:commandButton value="Cancel" action="{!cancel}" id="butcan"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
        <apex:pageBlock title="Selected Opportunities" id="muselectedlist">
            <apex:pageBlockTable value="{!selected}" var="opp" id="mutab">
                <apex:column value="{!opp.name}" id="oppname"/>
                <apex:column value="{!opp.stagename}" id="oppstage"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>
============================
============================

Apex Coding on Mass Delete Records Using List Button in Java Scripts.....



{!REQUIRESCRIPT("/soap/ajax/9.0/connection.js")}

var records = {!GETRECORDIDS( $ObjectType.Event )};
var taskRecords = {!GETRECORDIDS( $ObjectType.Task)};
records = records.concat(taskRecords);


if (records[0] == null) {
alert("Please select at least one record.") }
else {

var errors = [];
var result = sforce.connection.deleteIds(records);
if (result &result.length)
{
alert(result);
alert(result);
var numFailed = 0;
var numSucceeded = 0;
for (var i = 0; i < result.length; i++){
alert(i);
var res = result[i];
if (res && res.success == 'true'){
numSucceeded++;
} else {
var es = res.getArray("errors");
if (es.length > 0) {
errors.push(es[0].message);
}
numFailed++;
}
}
if (numFailed > 0){
alert("Failed: " + numFailed + "\nSucceeded: " + numSucceeded + " \n Due to: " + errors.join("\n"));
} else {
alert("Number of records deleted: " + numSucceeded);
}
}
window.location.reload();
}

Apex Coding on Email Lead .....




public class EmailNotifyLead
{
 public static void SendEmail(Lead[] lead)
 {
  for (Lead l:lead)
 
  {
      //Date obj = Date.today();
      //Integer n = DAY(TODAY());
       DateTime t = l.CreatedDate;
       String[] toAddresses = new String[] {l.Email};
      //DateTime t = DateTime.now();
      t = t.addDays(10);
    if (t != null)
    {  
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(toAddresses);
        mail.setReplyTo('sampath_thylak@yahoo.co.in');
        mail.setSenderDisplayName('ThylakSOft');
        mail.setSubject('Test Email From Force.com Sites');
        mail.setPlainTextBody('Test');
       
    }
 
   
   
  }
 }
}

Apex Coding on Sending Email................



Controller:
----------
public class SendEmailSample
{
    public String emailTo {get; set;}
    public String emailBody {get; set;}
    public String response {get; set;}
    String[] Users = new String[]{};
    //string Users = null;
 
    public string[] getUsers()
    {
      Return Users;
    }
 
    public void setUsers(string[] Users)
    {
     this.Users=Users;  
    }

 public List<SelectOption> getItems()    
    {
        List<SelectOption> options = new List<SelectOption>();  
        List<User> UserVar = [Select u.Email, u.Name from User u];            
        for(User U : UserVar)      
        {            
          options.add(new SelectOption(U.Email,U.Name ));    
        }        
        return options;        
    }
     
    public PageReference sendEmail(){
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(Users);
        mail.setReplyTo('arjunan@yahoo.com');
        mail.setSenderDisplayName('Thylak SOFT');
        mail.setSubject('Test Email From Force.com Sites');
        mail.setPlainTextBody(emailBody);
        try{
            Messaging.SendEmailResult[] resultMail = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
            if(resultMail[0].isSuccess())
                return Page.opptyStep2;
                //response = 'ok sent!';
            else{
                response = resultMail[0].getErrors().get(0).getMessage();
            }
        }catch(System.EmailException ex){
            response = ex.getMessage();
        }  
        return null;
    }
   
    public PageReference test()
    {
      return null;
    }
}



Page Editor:
------------
<APEX:PAGE controller="SendEmailSample"  sidebar="true"  standardStylesheets="true" showHeader="true"  >
    <APEX:FORM >
        <APEX:PANELGRID columns="2" border="0" cellspacing="2">
            <APEX:OUTPUTTEXT value="Email To :"></APEX:OUTPUTTEXT>
            <apex:selectList size="5" multiselect="true" value="{!Users}" style="width:400px">
            <apex:selectOptions value="{!items}" ></apex:selectOptions>
            </apex:selectList>
            <APEX:OUTPUTTEXT value="Email Body :"></APEX:OUTPUTTEXT>
            <APEX:INPUTTEXTAREA style="WIDTH: 400px; HEIGHT: 100px" value="{!emailBody}"></APEX:INPUTTEXTAREA>
            <APEX:COMMANDBUTTON value="Send" rerender="statusMail" action="{!sendEmail}"></APEX:COMMANDBUTTON>                  
            <APEX:OUTPUTPANEL id="statusMail" layout="block">
                <STRONG><APEX:OUTPUTTEXT value="{!response}"></APEX:OUTPUTTEXT></STRONG>
            </APEX:OUTPUTPANEL>
        </APEX:PANELGRID>
    </APEX:FORM>
    <apex:outputPanel id="out">
<apex:actionstatus id="status" startText="Loading...">
<apex:facet name="stop">
<apex:outputPanel >
<!--<p>You have selected:</p>-->
<apex:dataList value="{!Users}" var="c">a:{!c}</apex:dataList>
</apex:outputPanel>
</apex:facet>
</apex:actionstatus>
</apex:outputPanel>
</APEX:PAGE>