Posts

Showing posts from April, 2016

Insert CSV file into a object

<apex:page standardController="Inserting_Record__c" extensions="HWCSVFileRead" showHeader="false"  sidebar="false">     <apex:form >     <apex:pageBlock >         <apex:pageBlockSection >                 <apex:outputText >Select The File</apex:outputText>             <apex:inputFile value="{!body}" />             </apex:pageBlockSection>                       <apex:commandButton value="Save" action="{!importingCSVFile}" />         </apex:pageBlock>     </apex:form> </apex:page> public class HWCSVFileRead {     public string stringVal {set;get;}     public string[] liststring {set;get;}     public Blob body {set;get;}     public list<medical__c> medical {set;get;}     public list<medical__c> medical1 {set;get;}     public list<medical__c> medical2 {set;get;}

Count Of Contacts

trigger CountOfContact on Contact (after insert, after update, after delete) {          list<account> acc=[select id, number__c, (select id, accountid from contacts) from Account];     list<account> act=new list<account>();     for(account aa:acc){         aa.number__c = aa.contacts.size();         act.add(aa);     }     update act; }