• Ramakarry
  • NEWBIE
  • 0 Points
  • Member since 2015
  • salesforcedeveloper
  • JktechnosoftLTD

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 3
    Replies
Hi Folks,
My recordsetVar is not displaying records even the object is having records in my Org.
Please find the peiece of code below and corresponding UI

<apex:page standardController="Account" recordSetVar="records" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!records}" var="r">
    <apex:column headerValue="Name" value="{!r.Name}"/>
    <apex:column headerValue="Phone" value="{!r.Phone}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form> </apex:page>

User-added image

Regards
Rama
 
Hi friends !
I have below snippet code which actually prevent duplicate contacts for an Account..but it's preventing every record to be insert...
trigger dupconprevention on Contact (Before Insert,Before Update) {
Map<String,Contact> lstb2 = new Map<String,Contact>();
for(Contact c:trigger.new){
if(lstb2.containskey(c.LastName) && lstb2.get(c.LastName).AccountId == c.AccountId){
contact cc = lstb2.get(c.LastName);
c.LastName.addError('Another contact with same Name exist');
}else
lstb2.put(c.LastName,c);
system.debug('my map'+lstb2);
}

for(Contact c:[select Id,AccountId,LastName from Contact where LastName In:lstb2.keyset()]){
Contact c2 = lstb2.get(c.LastName);
system.debug('Contact to be insert'+c2);
if((c.AccountId == c2.AccountId) && (c.LastName == c2.LastName)){
c2.LastName.addError('Already Exist');
}
}
Hai Friends !
Im trying to display records from Leads and Contact in a wrapped pageblock table using standard set controller.
Its confusing how to call records from multiple objects using standard set controller methods.
Can any body correct me?

public class myclass{
public ApexPages.StandardSetController lee{get;set;}  
public ApexPages.StandardSetController con{get;set;}

public List<LeadWrapperCls> records{get;set;}
Public Integer noOfRecords{get; set;}
Public Integer size{get;set;}

public myclass()
        {  
      records = new List<LeadWrapperCls>();
      lee = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id, LastName, MobilePhone,Email FROM Lead]));    
      con = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id, LastName, MobilePhone,Email FROM Contact]));  
      
      lee.setPageNumber(1);     
      lee.setPageSize(5);
      con.setPageSize(5);
      oppt.setPageSize(5);
      noOfRecords = lee.getResultSize() + con.getResultSize();
      getrecords();
      }
  public List<LeadWrapperCls> getrecords()
         {
       
        records = new List<LeadWrapperCls>();  
                for(Lead category : (List<Lead>)lee.getRecords())
                    {
                   records.add(new LeadWrapperCls(category));
                    system.debug('wrapper lead list' +records );                 
                    }                     
         
                  for(Contact category : (List<Contact>)con.getRecords())
                    {
                   records.add(new LeadWrapperCls(category));
                    system.debug('wrapper contact list' +records );
                  //  leadcollect  = new list<lead>();
                    }
                   return records ;
            }
            
            public Boolean hasNext {
        get {
            return lee.getHasNext();
        }
        set;
    }
    public Boolean hasPrevious {
        get {
            return lee.getHasPrevious();
        }
        set;
    }
 
    public Integer pageNumber {
        get {
            return lee.getPageNumber();
        }
        set;
    }
 
    public void first() {
        lee.first();
    }
 
    public void last() {
        lee.last();
    }
 
    public void previous() {
        lee.previous();
    }
 
    public void next() {
        lee.next();
    }   
public class LeadWrapperCls
   {
     public Boolean isSelected {get;set;}
     public Id  id{get;set;}
     public string name{get;set;}
     public string opp{get;set;}
     public String email{set;get;}
     public String phone{set;get;}
     public String type{set;get;}   
     public LeadWrapperCls(Lead llead){
     this.id = llead.Id;  
     this.name=llead.LastName;
     this.email=llead.Email;
     this.phone=llead.MobilePhone;     
      isSelected=false;
      type = 'Lead';
        }
        public LeadWrapperCls(Contact cCon){
        this.id = cCon.Id;  
     this.name=cCon.LastName;
     this.email=cCon.Email;
     this.phone=cCon.MobilePhone;     
      isSelected=false;
      type = 'Contact';
        }
        public LeadWrapperCls(Opportunity opp){
        this.id = opp.Id;  
              
      isSelected=false;
      type = 'Opportunity';
        }
    }
}
===========================================================
<apex:page controller="myclass" >
<apex:form id="fm">
  <apex:pageBlock rendered="{!b}">
   <apex:pageBlockButtons location="top">
      <apex:commandButton action="{!process}" value="Select" reRender="pb,fm"/>
      </apex:pageBlockButtons>
      <apex:pageBlockSection columns="1">
      
 <apex:pageblocktable value="{!records }" var="wrapper" id="pb" >
                <apex:column width="25px">                        
                    <apex:inputCheckbox value="{!wrapper.isSelected}"/>
                </apex:column>
                <apex:column value="{!wrapper.type}"/>
                <apex:column value="{!wrapper.id}"/>
                <apex:column value="{!wrapper.name}"/>
                <apex:column value="{!wrapper.email}"/>
                <apex:column value="{!wrapper.phone}"/>
   </apex:pageblocktable>
   <apex:panelGrid columns="7">
                <apex:commandButton status="fetchStatus" reRender="pb" value="first" action="{!first}" disabled="{!!hasPrevious}" title="First Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value="previous" action="{!previous}" disabled="{!!hasPrevious}" title="Previous Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value="Next" action="{!next}" disabled="{!!hasNext}" title="Next Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value="Last" action="{!last}" disabled="{!!hasNext}" title="Last Page"/>
            </apex:panelGrid>
            </apex:pageBlockSection>
   </apex:pageBlock>
   </apex:form>
</apex:page>
Hai !
while embedding flows with Vf page im redirecting flow to a pageblock table where i can select recordtypes.But once the selection is done   i want to  return to previous flow screen which is having few more screens to go through.
can any one help me to resolve as i'm new to flow.
Hai friends !
I ve displayed  map of events on a visualforce page using following code snippet...But here the issue is.......
I wana dispaly Startdatetime, Enddatetime fileds on visualforce page in local user time zone. Can any one help how do modify the bellow code which is currently displaying the datetime in GMT formate only?
Code:
<apex:page standardController="Event" extensions="mysamplecls" sidebar="false"  setup="false" showHeader="false">  
<apex:pagemessages /> 
<style>
.ct{
text-align:center;
}
</style>
   <apex:form > 
     <apex:pageBlock >
       <apex:pageBlockSection >       
         <apex:inputfield value="{!Event.startDateTime}" /><br/>
         <apex:inputField value="{!Event.EndDateTime}"/>
        </apex:pageBlockSection> 
      <apex:pageBlockButtons location="bottom">
           <apex:commandButton value="Search" action="{!Query}"/>
      </apex:pageBlockButtons>
      </apex:pageBlock>
      <apex:pageBlock title="Event List" id="pb" rendered="{!abool}">
      <apex:pageblockSection columns="1" >      
     <apex:pageBlockTable value="{!eventmap}" var="a"  rendered="{!(Events.size != 0)}">  
        
  
      <apex:column headerValue="Subject" width="1%" > <br/><br/>  
       <apex:repeat value="{!eventmap[a]}" var="e"> 
        <table>    
        
        <tr><td >{!e.Subject}</td></tr>       
               </table>  
        </apex:repeat>
        </apex:column>
      
        
        <apex:column headerValue="startdatetime" width="1%"> <br/><br/>      
        <apex:repeat value="{!eventmap[a]}" var="e">
        <table Width="50%">
        <tr width="1px"><td >
         <apex:outputText value="{0,date,dd/MM/yyyy HH:mm a}">
    <apex:param value="{!e.startdatetime}" /> 
</apex:outputText>
        
        </td></tr>       
        </table>
        </apex:repeat>
        </apex:column>
        
        <apex:column headerValue="Enddatetime" width="1%"> <br/>
        <table Width="50%"><th>
        <apex:outputText value="{!a}" style="font-weight:800" /><br/>
        </th></table>
        <apex:repeat value="{!eventmap[a]}" var="e">
        <table Width="50%">
        <tr><td><apex:outputText value="{0,date,dd/MM/yyyy HH:mm a}">
    <apex:param value="{!e.Enddatetime}" /> 
</apex:outputText></td></tr>       
        </table>
        </apex:repeat>
        </apex:column>
        <apex:column headerValue="Name" width="1%">  <br/><br/>  
        <apex:repeat value="{!eventmap[a]}" var="e">
        <table Width="50%">
        <tr><td>{!e.owner.name}</td></tr>  
        </table>
        </apex:repeat>
        </apex:column>  
</apex:pageBlockTable>    
</apex:pageBlockSection>
</apex:pageblock>
<table><tr><td align="center">
 <apex:outputText rendered="{!(Events.size = 0)}"  value="There are no Events to display."  />
 </td>
 </tr>
 </table>
 </apex:form>
</apex:page>
controller:
public with sharing class mysamplecls{ 
public Event e;    
public list<Event> Events{set;get;}
public  map<string, List<Event>> eventmap{set;get;}
 public Boolean abool {get;set;}
 public mysamplecls(ApexPages.StandardController controller) {
    e=(Event)controller.getrecord(); 
    }
//call the fetched Events to be display 

//fetch the Events between two required dates
public PageReference Query() { 
abool = false;
if(e.StartDateTime<e.EndDateTime){
Events=new list<Event>();
Events.clear();  
 eventmap=new map<string, List<Event>>();
 system.debug('eventmap'+eventmap); 
Events = [Select Subject,StartDateTime,EndDateTime,Owner.Name,CreatedDate from Event where StartDateTime >=: e.StartDateTime and EndDateTime<=:e.EndDateTime order BY StartDateTime];
system.debug('list of Events'+Events );
if(Events.size()>0){abool = true;}
Datetime d;
for (Event e : Events){ 
            
    if(e.StartDateTime!=null )
          {
           d=e.startdatetime; 
           list<event> mapevents=new list<event>();     
            if(d==e.startdatetime)
                  { 
                   TimeZone tz=UserInfo.getTimeZone();
            
                   mapevents.add(e);                  
                }             
                             
             if(eventmap.containskey(string.ValueOf(d.format('dd-MM-yyyy-EEEE')))){
             eventmap.get(string.ValueOf(d.format('dd-MM-yyyy-EEEE'))).add(e); 
 
         System.debug('mapelementstype1'+eventmap);
       }
else
eventmap.put(string.ValueOf(d.format('dd-MM-yyyy-EEEE')),mapevents );
    
system.debug('Event Map type2'+eventmap);
               }
                             
            }
          }
       
       else
       {
        if((e.StartDateTime==null || e.EndDateTime==null))
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Please Enter valid Date'));
        else
        if(e.StartDateTime>e.EndDateTime)
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'End date should be grater than start Date'));
        }
        return null;
       
    }
    }

 
hai friends !
Can any one plz fix the issue
Compile Error: Incompatible key type Datetime for Map<String,List<Event>> at line 51 column 1 for the bellow code
code:
public with sharing class samplecls{ 
public Event e;    
public list<Event> Events{set;get;}
public  map<string, List<Event>> eventmap{set;get;}
public Boolean abool {get;set;}
public samplecls(){
eventmap=new map<string, List<Event>>(); 
}
public samplecls(ApexPages.StandardController controller) {
    e=(Event)controller.getrecord();   
    }   
//fetch the Events between two required dates
public PageReference Query() {
abool = false; 
if(e.StartDateTime<e.EndDateTime){
Events=new list<Event>();
Events.clear(); 
eventmap=new map<string, List<Event>>();  
Events = [Select Subject,StartDateTime,EndDateTime,Owner.Name,CreatedDate from Event where StartDateTime >=: e.StartDateTime and EndDateTime<=:e.EndDateTime order BY StartDateTime];
system.debug('Events'+Events );
if(Events.size()>0){abool = true;}
Datetime d;
    for (Event e : Events){ 
             TimeZone tz=UserInfo.getTimeZone();  
             string t1 = e.StartDateTime.format('dd/MM/yyyy hh:mm a',tz.getId());
             e.StartDateTime = DateTime.parse(t1);
             string t2 = e.EndDateTime.format('dd/MM/yyyy hh:mm a',tz.getId());
             e.EndDateTime = DateTime.parse(t2);              
    if(e.StartDateTime!=null )
          {
           d=e.startdatetime;      
          list<event> mapevents=new list<event>();
                    for(Event che: Events )
              {
              if(d==che.startdatetime)
              mapevents.add(che);  
if(eventmap.get(che.StartDateTime)== null)  {
 eventmap.put(string.ValueOf(d.format('dd-MM-yyyy-EEEE')),mapevents );
         System.debug('mapelementstype1'+eventmap);
       }
else
eventmap.get(d).add(che);    
system.debug('Event Map type2'+eventmap);
               } 
               }
            }
          }
       
       else
       {
        if((e.StartDateTime==null || e.EndDateTime==null))
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Please Enter valid Date'));
        else
        if(e.StartDateTime>e.EndDateTime)
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'End date should be grater than start Date'));
        }
      return null;  
    }
    }
Hai friends! 
While displaying map values on a pageblock table every time i m getting below error...can any body help me how to understand this and fix?
Error:
Incorrect parameter type for subscript. Expected java.lang.Class, received DateTime
Error is in expression '{!eventmap[key]}' in component <apex:pageBlock> in page 
My code is:
<apex:page controller="DisplaySectionsController11">
<apex:form >
<apex:repeat value="{!eventmap}" var="key">
<apex:pageBlock title="{!key}">
<apex:pageblocktable value="{!eventmap[key]}" var="a">
<apex:column value="{!a.Subject}"/>
<apex:column value="{!a.Startdatetime}"/>
<apex:column value="{!a.Enddatetime}"/>
</apex:pageBlock>
</apex:repeat>
<apex:commandButton value="ss" action="{!Query}"/>
</apex:form>
</apex:page>
I have a requirement where i have displayed some Events between 2 different Date.
    But while i'm gona display them through pageblock table Group By StartDateTime, the query as follows is not suppoting 
    select Subject,StartDateTime,day_only(StartDateTime),EndDateTime,Owner.Name,CreatedDate, 
    from Event group by day_only(StartDateTime) 
Any body plz help to fix the error
Hai friends !
i ve a requirement where i hav a moderate user who is the member of 2 groups.Here how can i allow the moderate permission for that user work on only at 1st group not at 2nd group?is it possible through configuration or need to go for customization?
can any one plz let me knoe in detail how chatter is differ from chatterFeed?
Hai Friends !
Im trying to display records from Leads and Contact in a wrapped pageblock table using standard set controller.
Its confusing how to call records from multiple objects using standard set controller methods.
Can any body correct me?

public class myclass{
public ApexPages.StandardSetController lee{get;set;}  
public ApexPages.StandardSetController con{get;set;}

public List<LeadWrapperCls> records{get;set;}
Public Integer noOfRecords{get; set;}
Public Integer size{get;set;}

public myclass()
        {  
      records = new List<LeadWrapperCls>();
      lee = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id, LastName, MobilePhone,Email FROM Lead]));    
      con = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id, LastName, MobilePhone,Email FROM Contact]));  
      
      lee.setPageNumber(1);     
      lee.setPageSize(5);
      con.setPageSize(5);
      oppt.setPageSize(5);
      noOfRecords = lee.getResultSize() + con.getResultSize();
      getrecords();
      }
  public List<LeadWrapperCls> getrecords()
         {
       
        records = new List<LeadWrapperCls>();  
                for(Lead category : (List<Lead>)lee.getRecords())
                    {
                   records.add(new LeadWrapperCls(category));
                    system.debug('wrapper lead list' +records );                 
                    }                     
         
                  for(Contact category : (List<Contact>)con.getRecords())
                    {
                   records.add(new LeadWrapperCls(category));
                    system.debug('wrapper contact list' +records );
                  //  leadcollect  = new list<lead>();
                    }
                   return records ;
            }
            
            public Boolean hasNext {
        get {
            return lee.getHasNext();
        }
        set;
    }
    public Boolean hasPrevious {
        get {
            return lee.getHasPrevious();
        }
        set;
    }
 
    public Integer pageNumber {
        get {
            return lee.getPageNumber();
        }
        set;
    }
 
    public void first() {
        lee.first();
    }
 
    public void last() {
        lee.last();
    }
 
    public void previous() {
        lee.previous();
    }
 
    public void next() {
        lee.next();
    }   
public class LeadWrapperCls
   {
     public Boolean isSelected {get;set;}
     public Id  id{get;set;}
     public string name{get;set;}
     public string opp{get;set;}
     public String email{set;get;}
     public String phone{set;get;}
     public String type{set;get;}   
     public LeadWrapperCls(Lead llead){
     this.id = llead.Id;  
     this.name=llead.LastName;
     this.email=llead.Email;
     this.phone=llead.MobilePhone;     
      isSelected=false;
      type = 'Lead';
        }
        public LeadWrapperCls(Contact cCon){
        this.id = cCon.Id;  
     this.name=cCon.LastName;
     this.email=cCon.Email;
     this.phone=cCon.MobilePhone;     
      isSelected=false;
      type = 'Contact';
        }
        public LeadWrapperCls(Opportunity opp){
        this.id = opp.Id;  
              
      isSelected=false;
      type = 'Opportunity';
        }
    }
}
===========================================================
<apex:page controller="myclass" >
<apex:form id="fm">
  <apex:pageBlock rendered="{!b}">
   <apex:pageBlockButtons location="top">
      <apex:commandButton action="{!process}" value="Select" reRender="pb,fm"/>
      </apex:pageBlockButtons>
      <apex:pageBlockSection columns="1">
      
 <apex:pageblocktable value="{!records }" var="wrapper" id="pb" >
                <apex:column width="25px">                        
                    <apex:inputCheckbox value="{!wrapper.isSelected}"/>
                </apex:column>
                <apex:column value="{!wrapper.type}"/>
                <apex:column value="{!wrapper.id}"/>
                <apex:column value="{!wrapper.name}"/>
                <apex:column value="{!wrapper.email}"/>
                <apex:column value="{!wrapper.phone}"/>
   </apex:pageblocktable>
   <apex:panelGrid columns="7">
                <apex:commandButton status="fetchStatus" reRender="pb" value="first" action="{!first}" disabled="{!!hasPrevious}" title="First Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value="previous" action="{!previous}" disabled="{!!hasPrevious}" title="Previous Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value="Next" action="{!next}" disabled="{!!hasNext}" title="Next Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value="Last" action="{!last}" disabled="{!!hasNext}" title="Last Page"/>
            </apex:panelGrid>
            </apex:pageBlockSection>
   </apex:pageBlock>
   </apex:form>
</apex:page>
Hai !
while embedding flows with Vf page im redirecting flow to a pageblock table where i can select recordtypes.But once the selection is done   i want to  return to previous flow screen which is having few more screens to go through.
can any one help me to resolve as i'm new to flow.