• Joseph Barone
  • NEWBIE
  • 45 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 6
    Replies
Hello,

I've created a wrapper class that handles the specific data that I need.  When I output to VF, the data renders properly but now I'm trying to customize the output and am having issues.  

Here is what I currently have:
Current Output

What I'm looking for is to create a table for each change in TimeKeeper such that the header and the footer appears for each timekeeper.  

Below is both my Apex and VisualForce code.  Thank you in advanced for any help you may be able to provide.
 
<apex:page controller="StaffingController" cache="True" readonly="true" >
    <apex:pageMessages />
    
    <apex:variable value="{!0.00}" var="billable"/> <apex:variable value="{!0.00}" var="non"/>
    <apex:pageblock >
          
              
     <apex:pageBlockTable title="Test" value="{!result}" var="p">
         <!--     <apex:repeat value="{!result}" var="p">
              
          <apex:pageBlockTable value="{!p.timew}" var="q"> -->
              <apex:column headerValue="Employee" width="20"> <apex:outputField value="{!p.timew.Timekeeper__c}"/>
              </apex:column>
              <apex:column headerValue="Client" width="100"><apex:outputField value="{!p.timew.Client__c}"/>
              
         </apex:column>
              <apex:column headerValue="Matter" width="400"><apex:outputField value="{!p.timew.mcodes__c}"/> 
                  <apex:facet name="footer">SubTotal Billable: <span class="t1" /> <br/> SubTotal Non-Billable: <span class="t2" /></apex:facet>   
         </apex:column>
        
              <apex:column headerValue="Week1" >
              <apex:outputText value="{!p.P}" />
                  <apex:variable var="Billable" value="{!p.BillTime}" />      
         
         </apex:column>
              <apex:column headerValue="Week2" >
              <apex:outputText value="{!p.P}" /> 
                  <apex:variable var="non" value="{!p.NonBill}" />
              </apex:column>
              <apex:column headerValue="Week3" >
              <apex:outputText value="{!p.P}" /> 
              </apex:column>
              <apex:column headerValue="Week4" >
              <apex:outputText value="{!p.P}" /> 
              </apex:column>
              <apex:column headerValue="Week5" >
              <apex:outputText value="{!p.P}" /> 
              </apex:column>
              <apex:column headerValue="Week6" >
              <apex:outputText value="{!p.P}" /> 
              </apex:column>
              <apex:column headerValue="Week7" >
              <apex:outputText value="{!p.P}" /> 
              </apex:column>
              <apex:column headerValue="Week8" >
              <apex:outputText value="{!p.P}" /> 
              </apex:column>
              <apex:column headerValue="Week9" >
              <apex:outputText value="{!p.P}" /> 
              </apex:column>
              <apex:column headerValue="Week10" >
              <apex:outputText value="{!p.P}" /> 
              </apex:column>
              <apex:column headerValue="Week11" >
              <apex:outputText value="{!p.P}" /> 
              </apex:column>
              <apex:column headerValue="Week12" >
              <apex:outputText value="{!p.P}" /> 
              </apex:column>
               
      <!--   </apex:pageBlockTable> -->
          
        
         
         
              
              </apex:pageBlockTable>
        </apex:pageblock>
<script>
    document.getElementsByClassName('t1')[0].innerHTML = '{!Billable}';
    document.getElementsByClassName('t2')[0].innerHTML = '{!non}';
    
    </script>
</apex:page>
 
public class StaffingController {

    Public List<User> Professionals {get;set;}
    Public List<Time_Entry__c> timeE {get;set;}

    Public User[] getUsers()
    {
        system.debug('getUsers');
        return [select id, Name, Alias FROM User WHERE UserRole.Name = 'Professional' AND IsActive = True];
    }
 	
   
    Public list <Staffing> result {get;set;}
        
         
    Public StaffingController()
    {                
        Integer ProfCount = 1;
        system.debug ('in wrapper');
        result = new Staffing[]{};
        List <client__c> nonbillable1 = [select ID from Client__c Where Name='CMD' AND InActive__c=False LIMIT 1];
            string nonbillid = nonbillable1.get(0).id;
        User[] professionals = getUsers();
        system.debug('Called Professionals'+professionals);
        
        List<string> holder = new List<string>();
                
        for (user p : professionals)
        {holder.add(p.Alias);}

            List<Time_Entry__c> timeE= [Select Name,Client__c,mcodes__c,Date__c,Timekeeper__c,Hours_Worked__c From Time_Entry__c Where Timekeeper__c In :holder];
        system.debug(timeE);
        
          
        for (user p: professionals)
        {
            
            List<Time_Entry__c> ProfTime = new List <Time_Entry__c>();
            integer hoursworktotal =0;
            integer entrycount=0;
            double projection=0;
            double bill = 0.00;
            double non = 0.00;
            
            for (Time_Entry__c te: timeE)
            {
            	 if (p.alias == te.Timekeeper__c)
             	{
                 	ProfTime.add(te);
                    system.debug('Add Time to ProfTime'+ProfTime);
                }
            }
            
            for(integer i=0; i<ProfTime.size();i++)
            {
                system.debug('ProfTime Value'+i+'-'+ProfTime.get(i));
            }
            
            if(ProfTime.size()!=0)
            {	
                    	// ProfTime is Single User's Time Block.
            	entrycount=ProfTime.size();
           
         	   List <string> alldata =  new List<String> ();
            
           	 string x = Proftime.get(0).client__c;
            string y = Proftime.get(0).mcodes__c;
            string z = x + '-' + y;
            system.debug('z'+z);
            alldata.add(z);
            //client and matter combine
           for(integer k=1; k<entrycount; k++)
           {
               Boolean toadd = false; 
               string x1 = Proftime.get(k).client__c;
            	system.debug('x1'+x1);
               string y1 = Proftime.get(k).mcodes__c;
               system.debug('y1'+y1);
            	string z1 = x1 +'-'+ y1;
               system.debug('z1'+z1);
            		
               for(string ad: alldata)
               {
                   if (z1 <> ad)
                   {
                      
                       toadd=true;
                       
                   }
                   else
                   {toadd=false;}
               }
               if(toadd == true)
               {
                   alldata.add(z1);
           
           		}
           }
            system.debug('alldata'+ alldata);
           for (string running: alldata)
           {
               
               Double totalhours=0.0;
               date firstentry = ProfTime.get(0).date__c;
               date lastentry = ProfTime.get(0).date__c;
              
               Time_Entry__c timetransfer = new Time_Entry__c ();
               for(Time_Entry__c tec1 : ProfTime)
               {
                string a1 = tec1.client__c;
                string b1 = tec1.mcodes__c;
            	string c1 = a1 +'-'+ b1;
                system.debug(running+ '==' +c1);
                   if(running == c1)
                   {
                       if(tec1.Client__c == nonbillid)
                       {
                           non+=tec1.Hours_Worked__c;
                       }
                       else
                       {
                           bill+=tec1.Hours_Worked__c;
                       }
                       totalhours+=tec1.Hours_Worked__c;
                       timetransfer = tec1;
                       system.debug(totalhours);
                       if(tec1.date__c < firstentry)
                       {
                           firstentry = tec1.date__c;
                       }
                       if(tec1.date__c > lastentry)
                       {
                           lastentry = tec1.date__c;
                       }
                   }
                             
               }
               system.debug(firstentry+' '+lastentry);
               Integer noOfDays = firstentry.daysBetween(lastentry)+1;
               system.debug(noOfDays + 'number of days');
               
               if(noOfDays > 7)
               {               
               Decimal Average = totalhours / noOfDays;
               system.debug(average);
               decimal Sday = Math.round(Average*7);
               projection = double.valueof(Sday);
               }
               else
               {projection = totalhours;}
               
               
            result.add(new Staffing(timetransfer,projection,bill,non, ProfCount));
               system.debug(result.size()+'result size');
           }
          
            }
            ProfCount++;
            }  
        
      }

    Public class Staffing
    {
        public Time_Entry__c timew {get;set;}
        public Double P {get;set;}
  

        Public decimal BillTime {get;set;}
        Public decimal NonBill {get;set;}
        Public integer profcount {get;set;}
        
        
        
        public Staffing(Time_Entry__c timew1, Double P1, Double Billable, Double non, integer loopcount)
        {
            timew=timew1;
            P=P1;
            BillTime=Billable;
            NonBill=non;
            profcount=loopcount;
            
         
        }
    }
}

 
Hello,

I've been beating my head against a brink wall for a few days now.  I've gotten the test class for my custom controller to run successfully, but get zero code coverage.  I've read so many different website and forums that I do not know what is correct.  I've pasted both my Controller and Test Class below.  

Thank you!
 
public class Tier1Report {

    
    public string idCurrentUser {get;set;}
    
    Public List <Contact> filteredContact;
    Public List <CM_Relationship__c> filteredCMrelationshipcontact;
    Public List <Contact> cmContacts{get;set;}
    Public List <Contact> selected {get;set;}
    
    
    public Tier1Report ()
    {
        
        idCurrentUser = UserInfo.getUserId();
        system.debug(idCurrentUser);
        
        selected=new list<Contact>();
        
        filteredContact = [Select ID, name,accountID,Weeks_Last_Contacted__c FROM Contact Where ownerid = :idCurrentuser AND Referral_Tier__c='1 - Direct'];
             
        
        filteredCMrelationshipcontact = ([Select ID, Contact__c From CM_Relationship__c where Owner__c = :idCurrentuser]);
		
        Set<String> CMstringID = new Set<String>();       
        for(integer i=0;i<filteredCMrelationshipcontact.size();i++)
        {
           
         CMStringID.add(filteredCMrelationshipcontact.get(i).Contact__c);
           
		}
        
        Map<Id,Contact> CMcontact = new Map<Id,Contact>([Select ID, name,accountID,Weeks_Last_Contacted__c FROM Contact Where Id IN :CMStringID AND Referral_Tier__c='1 - Direct']);
        system.debug(CMcontact);
         for (Contact c:filteredContact)
         {
             if(c.weeks_last_contacted__c >= 2)
             {
             	if(CMcontact.containsKey(c.id)==False)
             	{
                 selected.add(c);
             	}
             }
         }
         
        for(Contact cmap: CMcontact.values())
        {
            if(cmap.Weeks_Last_Contacted__c >= 2)
            {
            selected.add(cmap);
            }
        }
                
            
        }
            
     }
 
@isTest

private class Tier1Test {
static user testuser;
    
    static testMethod void validateTier1Report(){

       profile p =[select id from profile where name='All but IT'];
        
      testUser = new User(alias = 'u1', email='u1@testorg.com',
      emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
      localesidkey='en_US', profileid = p.Id, country='United States',
      timezonesidkey='America/Los_Angeles', username='u1@testorg.com');

    insert testUser;
    string uid = testuser.Id;    
        
          
        Tier1Report controller = new Tier1Report();
       controller.idcurrentuser = uid;
        
        Account ac = new Account();
      	ac.name = 'Testing class';
       ac.phone = '5555555555';
        ac.industry = 'ASP';
        ac.website = 'http://www.testing.com';
		ac.ownerid = uid;      
       
        insert ac;
        system.assertEquals('Testing class',ac.name);
        
        string Accountid = ac.id;
        
        Contact nc = new Contact();
        nc.lastname = 'Testing Name';
        nc.accountid = Accountid;
        nc.referral_tier__c = '1 - Direct';
        nc.ownerid = uid;
        
       insert nc;
        system.assertEquals('1 - Direct',nc.referral_tier__c);
        string Contactid = nc.id;
        string userid2 = nc.ownerid;
               
        Event ne = new Event ();
        ne.subject = 'Testing Class works';
        ne.whoid = contactid;
        ne.startdatetime = datetime.newinstance(2015,2,1,8,5,0);
        ne.enddatetime = datetime.newinstance(2015,2,1,9,5,0);
        
        insert ne;
        system.assertEquals('Testing Class works',ne.subject);
        
        CM_Relationship__c ncm = new CM_Relationship__c ();
        ncm.contact__c = contactid;
        ncm.owner__c = uid;
        insert ncm;
        
        test.starttest();
        List <Contact> ctest = [Select ID, name FROM Contact Where Referral_Tier__c='1 - Direct'];
		List <CM_Relationship__c> cmtest = [Select id, owner__c, contact__c From CM_Relationship__c Limit 1];
            
        test.stoptest();
        system.AssertEquals(1,ctest.size());
        system.assertEquals(1,cmtest.size());
        
   
    }
}

 
Hello,

I have a VF page that allows for multiple entries to be created on the same page.  Two of the fields I'm referencing are Parent- Child lookup fields that I've created as a picklist (one is Client and other is Matter).  Matter is dependent on Client.  

The picklists works great and provide the right details.  The issue I run into is when I go to add in a new record, the Picklists retain their values from the previous entry.  If I try to change the entries, it gives me validation error.  As soon as I change the values back to the previous line it works great.   I have a feeling it is tied to how I have the VF page created, but I'm not 100 % sure.  Any suggestions would be appreciated.

Thank you,

 
<apex:page Controller="AddmultipleTimes" sidebar="false" action="{!setInitials}">
    
    <apex:form >
         
    <apex:pageBlock mode="edit" id="title">
    <table width="100%" border="0">
         <tr>
         <td width="100" valign="top">
         
     <apex:pageBlock title="Change Timekeeper" mode="edit" id="initialchange">
        
          <table cellpadded="2" cellspacing="2">
          <tr>
         <apex:inputtext value="{!initials2}" />
         <apex:commandButton action="{!newTimeKeeper}" value=" Submit Initials " style="color:red" reRender="thetable, mainpage">
                    
            </apex:commandButton>
          </tr>
          </table>         
        
        </apex:pageBlock>
             </td>
        <td valign="top">
        <apex:pageblock id="mainpage" title="New Time Entries for {!initials}" >
        
             <apex:pageMessages />
         
              
            <apex:pageblocktable value="{!listNewtime}" var="lnt" id="thetable"> <apex:variable value="{!0}" var="cnt"/>
              
            
                
                <apex:column width="100px">
                <apex:commandButton action="{!removeLine}" value=" X " style="color:red" reRender="thetable">
            <apex:param name="TimeCount" assignTo="{!TimeCount}" value="{!cnt}"/>
            
            </apex:commandButton>
          </apex:column>
                <apex:column >
                <apex:commandButton action="{!copyValues}" value="Copy" reRender="thetable">
                <apex:param name="TimeCount2" assignTo="{!TimeCount2}" value="{!cnt}"/>
                </apex:commandButton>
                </apex:column>
           
                <apex:column headerValue="Entry">   
                <apex:outputText value="{!cnt}" />
               <apex:variable var="cnt" value="{!cnt+1}"/>       
                                       
                </apex:column>
       
        <apex:column headerValue="Date">
            <apex:inputField value="{!lnt.Date__c}"/>
        </apex:column>
        
        <apex:column headerValue="Client Code">
        <apex:inputField value="{!lnt.Client_Code__c}" />
        </apex:column>
        <apex:column width="100px" headerValue="Matter #">
        <apex:inputField value="{!lnt.Matter__c}" />
        </apex:column>
                
        <apex:column headerValue="Client Code -- Test">
   		<apex:selectList size="1" value="{!clientc}">
            <apex:selectoptions value="{!clientobj}"/>
            <apex:actionSupport event="onchange" reRender="MatterList"/>
            </apex:selectList>
          
         
        </apex:column>
        <apex:column width="100px" headerValue="Matter # -- Test">
        <apex:selectList size="1" value="{!matt}" id="MatterList">
            <apex:selectoptions value="{!mattobj}"/>
            <apex:actionSupport event="onchange" />
            </apex:selectList>
                         
 
        </apex:column>
         
        <apex:column width="100px" headerValue="Hours">
        <apex:inputField value="{!lnt.Hours_Worked__c}"  style="width: 100px"/>
        </apex:column>
        <apex:column width="100px" headerValue="Task">
        <apex:inputField value="{!lnt.Tasks__c}" style="width: 100px"/>
        </apex:column>          
        <apex:column width="1000px" headerValue="Narrative">
            <apex:inputField value="{!lnt.Narrative__c}" style="width: 1000px"/>
        </apex:column>
  
        
            </apex:pageblocktable>
      
            
        <apex:pageBlockButtons >
            <apex:commandbutton value="Add New Row" action="{!addTime}" rerender="thetable"/>
            <apex:commandButton value="Save Times" action="{!saveTime}"/>
            
            </apex:pageBlockButtons>
            </apex:pageblock>
             </td>
        </tr>
        </table>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 
Hello,

I have a VF page that allows for multiple entries to be created on the same page.  Two of the fields I'm referencing are Parent- Child lookup fields that I've created as a picklist (one is Client and other is Matter).  Matter is dependent on Client.  

The picklists works great and provide the right details.  The issue I run into is when I go to add in a new record, the Picklists retain their values from the previous entry.  If I try to change the entries, it gives me validation error.  As soon as I change the values back to the previous line it works great.   I have a feeling it is tied to how I have the VF page created, but I'm not 100 % sure.  Any suggestions would be appreciated.

Thank you,
 
<apex:page Controller="AddmultipleTimes" sidebar="false" action="{!setInitials}">
    
    <apex:form >
         
    <apex:pageBlock mode="edit" id="title">
    <table width="100%" border="0">
         <tr>
         <td width="100" valign="top">
         
     <apex:pageBlock title="Change Timekeeper" mode="edit" id="initialchange">
        
          <table cellpadded="2" cellspacing="2">
          <tr>
         <apex:inputtext value="{!initials2}" />
         <apex:commandButton action="{!newTimeKeeper}" value=" Submit Initials " style="color:red" reRender="thetable, mainpage">
                    
            </apex:commandButton>
          </tr>
          </table>         
        
        </apex:pageBlock>
             </td>
        <td valign="top">
        <apex:pageblock id="mainpage" title="New Time Entries for {!initials}" >
        
             <apex:pageMessages />
         
              
            <apex:pageblocktable value="{!listNewtime}" var="lnt" id="thetable"> <apex:variable value="{!0}" var="cnt"/>
              
            
                
                <apex:column width="100px">
                <apex:commandButton action="{!removeLine}" value=" X " style="color:red" reRender="thetable">
            <apex:param name="TimeCount" assignTo="{!TimeCount}" value="{!cnt}"/>
            
            </apex:commandButton>
          </apex:column>
                <apex:column >
                <apex:commandButton action="{!copyValues}" value="Copy" reRender="thetable">
                <apex:param name="TimeCount2" assignTo="{!TimeCount2}" value="{!cnt}"/>
                </apex:commandButton>
                </apex:column>
           
                <apex:column headerValue="Entry">   
                <apex:outputText value="{!cnt}" />
               <apex:variable var="cnt" value="{!cnt+1}"/>       
                                       
                </apex:column>
       
        <apex:column headerValue="Date">
            <apex:inputField value="{!lnt.Date__c}"/>
        </apex:column>
        
        <apex:column headerValue="Client Code">
        <apex:inputField value="{!lnt.Client_Code__c}" />
        </apex:column>
        <apex:column width="100px" headerValue="Matter #">
        <apex:inputField value="{!lnt.Matter__c}" />
        </apex:column>
                
        <apex:column headerValue="Client Code -- Test">
   		<apex:selectList size="1" value="{!clientc}">
            <apex:selectoptions value="{!clientobj}"/>
            <apex:actionSupport event="onchange" reRender="MatterList"/>
            </apex:selectList>
          
        </apex:column>
        <apex:column width="100px" headerValue="Matter # -- Test">
        <apex:selectList size="1" value="{!matt}" id="MatterList">
            <apex:selectoptions value="{!mattobj}"/>
            <apex:actionSupport event="onchange" />
            </apex:selectList>
                       
         </apex:column>
         
        <apex:column width="100px" headerValue="Hours">
        <apex:inputField value="{!lnt.Hours_Worked__c}"  style="width: 100px"/>
        </apex:column>
        <apex:column width="100px" headerValue="Task">
        <apex:inputField value="{!lnt.Tasks__c}" style="width: 100px"/>
        </apex:column>          
        <apex:column width="1000px" headerValue="Narrative">
            <apex:inputField value="{!lnt.Narrative__c}" style="width: 1000px"/>
        </apex:column>
  
        
            </apex:pageblocktable>
      
            
        <apex:pageBlockButtons >
            <apex:commandbutton value="Add New Row" action="{!addTime}" rerender="thetable"/>
            <apex:commandButton value="Save Times" action="{!saveTime}"/>
            
            </apex:pageBlockButtons>
            </apex:pageblock>
             </td>
        </tr>
        </table>
        </apex:pageBlock>
    </apex:form>
</apex:page>



 
Hello All,

I need help cleaning up my code as I continually hit Too many SOQL queries: 101.  Upon reading the forums, I understand the reasoning for this issue, but cannot figure out a way around it.  

What I'm trying to do is create a list of all Activities per an Account.  The VF page and code is activated by a detailed link button on the page.  The account id is passed into the Controller and is used to query the EventRelations for all Events where AccountID = specific account id.  From the EventRelations query, I want to take the Event ID and query all the pertanent Event info.  The code I have below works fine, except when I have accounts with over X amount of activities.  

I've been able to write a query in the form of [Select ..., (Select ... From EventRelations) From Events ... ], but we have over 25000 events.  Querying the EventRelations first, helps limit the amount of Events that I need to look at. 

Any help would be greatly appreciated.  

Thank you
 
public class ActivitiesbyAccountController {

    public string idCurrentEvent {get;set;}
    Public Event evententry;
    Public List <EventRelation> eventconnect;
    Public List <Event> selected {get;set;}
    
    
    public ActivitiesbyAccountController(ApexPages.StandardController Account)
    {
        
        idCurrentEvent = ApexPages.currentPage().getParameters().get('id');
        
        
        selected=new list<Event>();
        
        eventconnect = [Select ID, relationid, eventid FROM EventRelation Where accountid = :idCurrentEvent AND IsDeleted = False];
        
        for(integer i=0;i<eventconnect.size();i++)
        {
         	
            if(eventconnect.get(i).relationid != idCurrentEvent)
       			  {
             		
                      Event newevent = new Event();
          			string tempeventid = eventconnect.get(i).eventid;
					 
          			newevent = [Select ID, OwnerID, subject, purpose_of_meeting__c, ActivityDate,WhatID From Event WHERE id = :tempeventid LIMIT 1000 ALL ROWS];
          			newevent.whoid = eventconnect.get(i).relationid;  
      				
        			selected.add(newevent);  
        		 }
            
         }
     }
}

 
I've created a small VF Page and Controller that exports Events pertaining to a specific Account.  The detailed link is on the Account Page and when clicked, passes the account.id to the Controller.  The Controller then references the EventRelation table and queries all the EventIDs to get all the Event Information and lists this on the Visual Force Page.  The VF page is set to automatically export into Excel.  

In my partial sandbox, all of the coding and testing works great.  The results are exactly what I'm expecting to get. 

However, when I deploy into production, I run into an issue.  It deploys perfectly and when I click the the detailed link on the Accounts Page, I get an error saying there are Zero Rows to select.  

I put in system.debugs to trace and also exported all EventRelations using Data Loader.  In my debug, I can see the EventID being referenced existing in the EventRelations table.  I've event copied the EventID and pasted into the browser and it took me to the correct event.  Ultimately, I'm trying to figure out why the query is returning zero results only in production.  

Any help is greatly appreciated!

Here is the controller code:
 
public class ActivitiesbyAccountController {

    public string idCurrentEvent {get;set;}
    Public Event evententry;
    Public List <EventRelation> eventconnect;
    Public List <Event> selected {get;set;}
    
    
    public ActivitiesbyAccountController(ApexPages.StandardController Account)
    {
        
        idCurrentEvent = ApexPages.currentPage().getParameters().get('id');
        system.debug(idCurrentEvent);
        
        selected=new list<Event>();
        
        eventconnect = [Select ID, relationid, eventid FROM EventRelation Where accountid = :idCurrentEvent];
        system.debug(eventconnect.size());
        system.debug(eventconnect);
        for(integer i=0;i<eventconnect.size();i++)
        {
         	system.debug('inside for loop');
            system.debug(i);
            system.debug(eventconnect.get(i).relationid +' ' + idCurrentEvent);
            if(eventconnect.get(i).relationid != idCurrentEvent)
       			  {
             		system.debug('inside if statement');
                      Event newevent = new Event();
          			string tempeventid = eventconnect.get(i).eventid;
					system.debug(tempeventid);            
          			newevent = [Select ID, OwnerID, subject, purpose_of_meeting__c, ActivityDate,WhatID From Event WHERE id = :tempeventid];
          			newevent.whoid = eventconnect.get(i).relationid;  
      				system.debug(newevent);
        			selected.add(newevent);  
        		 }
            
         }
     }
}


 
Hi all,

I've been reading forum after forum, post after post and still am getting no where.  Hopefully, one of you smart people can help me out.  

I have a command button on my VF page that when pressed, I want to send a value to the controller and have it dynamically delete that line.  This issue I am running into is I cannot get the value of my Param into the controller.  

Here is the code - 
 
<apex:page Controller="AddmultipleTimes">
    <apex:form >

        <apex:pageblock title="New Time Entries">
        
            <apex:pageblocktable value="{!listNewtime}" var="lnt" id="thetable"> <apex:variable value="{!0}" var="cnt"/>
     <apex:pageMessages />
        <apex:column width="100px">
        <apex:commandButton action="{!removeLine}" value=" X " reRender="thetable"/>
            <apex:param name="TimeCount" assignTo="{!removeLine}" value="{!cnt}"/>
                <apex:variable var="cnt" value="{!cnt+1}"/>
Controller -
 
public class AddmultipleTimes {
Time_Entry__c newtime = new Time_Entry__c();
    
    public list<Time_Entry__c>listNewtime{ get;set;}
    public Integer TimeCount {get;set;}
    
    public AddmultipleTimes()
    {
 //       TimeCount = 0;
        listNewtime=new list<Time_Entry__c>();
        listNewtime.add(newtime);
    }
    
    public void addTime()
    {
       
        Time_Entry__c newEntry = new Time_Entry__c();
//    	TimeCount = TimeCount + 1;
        listNewtime.add(newEntry);
        
               
    }
    
  
    public PageReference removeLine()
    { 
 		
        
        String indexVal = ApexPages.currentPage().getParameters().get('TimeCount');    
		
  
        integer TimeCount1 = integer.valueof(indexVal); 
       
        listNewTime.remove(TimeCount1);
 
            return null;
    }

Any help would be much appreciated.

Thank you
 
Hello All,

I have created a VisualForce page with a list that allows the end user to enter the values into the fields all at once.  At the end of each row, they have an option to add another row or to save all the data.  

In standard view, I have a verification rule on one of the Field X that makes sure if Field Y equals a specific value, then Field X cannot be Null.  This works great in the Standard view; however throws an exception error when entering through the VF list.  

I am not sure how to write a code for the VF list that verifies that Field X is not Null when Field Y equals a specific value.  Moreover, I have my list listNewTime and I do not know how to access the data temporarily being stored there prior to running the insert command.  

Thank you in advance. 
Hello,

I've been beating my head against a brink wall for a few days now.  I've gotten the test class for my custom controller to run successfully, but get zero code coverage.  I've read so many different website and forums that I do not know what is correct.  I've pasted both my Controller and Test Class below.  

Thank you!
 
public class Tier1Report {

    
    public string idCurrentUser {get;set;}
    
    Public List <Contact> filteredContact;
    Public List <CM_Relationship__c> filteredCMrelationshipcontact;
    Public List <Contact> cmContacts{get;set;}
    Public List <Contact> selected {get;set;}
    
    
    public Tier1Report ()
    {
        
        idCurrentUser = UserInfo.getUserId();
        system.debug(idCurrentUser);
        
        selected=new list<Contact>();
        
        filteredContact = [Select ID, name,accountID,Weeks_Last_Contacted__c FROM Contact Where ownerid = :idCurrentuser AND Referral_Tier__c='1 - Direct'];
             
        
        filteredCMrelationshipcontact = ([Select ID, Contact__c From CM_Relationship__c where Owner__c = :idCurrentuser]);
		
        Set<String> CMstringID = new Set<String>();       
        for(integer i=0;i<filteredCMrelationshipcontact.size();i++)
        {
           
         CMStringID.add(filteredCMrelationshipcontact.get(i).Contact__c);
           
		}
        
        Map<Id,Contact> CMcontact = new Map<Id,Contact>([Select ID, name,accountID,Weeks_Last_Contacted__c FROM Contact Where Id IN :CMStringID AND Referral_Tier__c='1 - Direct']);
        system.debug(CMcontact);
         for (Contact c:filteredContact)
         {
             if(c.weeks_last_contacted__c >= 2)
             {
             	if(CMcontact.containsKey(c.id)==False)
             	{
                 selected.add(c);
             	}
             }
         }
         
        for(Contact cmap: CMcontact.values())
        {
            if(cmap.Weeks_Last_Contacted__c >= 2)
            {
            selected.add(cmap);
            }
        }
                
            
        }
            
     }
 
@isTest

private class Tier1Test {
static user testuser;
    
    static testMethod void validateTier1Report(){

       profile p =[select id from profile where name='All but IT'];
        
      testUser = new User(alias = 'u1', email='u1@testorg.com',
      emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
      localesidkey='en_US', profileid = p.Id, country='United States',
      timezonesidkey='America/Los_Angeles', username='u1@testorg.com');

    insert testUser;
    string uid = testuser.Id;    
        
          
        Tier1Report controller = new Tier1Report();
       controller.idcurrentuser = uid;
        
        Account ac = new Account();
      	ac.name = 'Testing class';
       ac.phone = '5555555555';
        ac.industry = 'ASP';
        ac.website = 'http://www.testing.com';
		ac.ownerid = uid;      
       
        insert ac;
        system.assertEquals('Testing class',ac.name);
        
        string Accountid = ac.id;
        
        Contact nc = new Contact();
        nc.lastname = 'Testing Name';
        nc.accountid = Accountid;
        nc.referral_tier__c = '1 - Direct';
        nc.ownerid = uid;
        
       insert nc;
        system.assertEquals('1 - Direct',nc.referral_tier__c);
        string Contactid = nc.id;
        string userid2 = nc.ownerid;
               
        Event ne = new Event ();
        ne.subject = 'Testing Class works';
        ne.whoid = contactid;
        ne.startdatetime = datetime.newinstance(2015,2,1,8,5,0);
        ne.enddatetime = datetime.newinstance(2015,2,1,9,5,0);
        
        insert ne;
        system.assertEquals('Testing Class works',ne.subject);
        
        CM_Relationship__c ncm = new CM_Relationship__c ();
        ncm.contact__c = contactid;
        ncm.owner__c = uid;
        insert ncm;
        
        test.starttest();
        List <Contact> ctest = [Select ID, name FROM Contact Where Referral_Tier__c='1 - Direct'];
		List <CM_Relationship__c> cmtest = [Select id, owner__c, contact__c From CM_Relationship__c Limit 1];
            
        test.stoptest();
        system.AssertEquals(1,ctest.size());
        system.assertEquals(1,cmtest.size());
        
   
    }
}

 
Hello,

I have a VF page that allows for multiple entries to be created on the same page.  Two of the fields I'm referencing are Parent- Child lookup fields that I've created as a picklist (one is Client and other is Matter).  Matter is dependent on Client.  

The picklists works great and provide the right details.  The issue I run into is when I go to add in a new record, the Picklists retain their values from the previous entry.  If I try to change the entries, it gives me validation error.  As soon as I change the values back to the previous line it works great.   I have a feeling it is tied to how I have the VF page created, but I'm not 100 % sure.  Any suggestions would be appreciated.

Thank you,

 
<apex:page Controller="AddmultipleTimes" sidebar="false" action="{!setInitials}">
    
    <apex:form >
         
    <apex:pageBlock mode="edit" id="title">
    <table width="100%" border="0">
         <tr>
         <td width="100" valign="top">
         
     <apex:pageBlock title="Change Timekeeper" mode="edit" id="initialchange">
        
          <table cellpadded="2" cellspacing="2">
          <tr>
         <apex:inputtext value="{!initials2}" />
         <apex:commandButton action="{!newTimeKeeper}" value=" Submit Initials " style="color:red" reRender="thetable, mainpage">
                    
            </apex:commandButton>
          </tr>
          </table>         
        
        </apex:pageBlock>
             </td>
        <td valign="top">
        <apex:pageblock id="mainpage" title="New Time Entries for {!initials}" >
        
             <apex:pageMessages />
         
              
            <apex:pageblocktable value="{!listNewtime}" var="lnt" id="thetable"> <apex:variable value="{!0}" var="cnt"/>
              
            
                
                <apex:column width="100px">
                <apex:commandButton action="{!removeLine}" value=" X " style="color:red" reRender="thetable">
            <apex:param name="TimeCount" assignTo="{!TimeCount}" value="{!cnt}"/>
            
            </apex:commandButton>
          </apex:column>
                <apex:column >
                <apex:commandButton action="{!copyValues}" value="Copy" reRender="thetable">
                <apex:param name="TimeCount2" assignTo="{!TimeCount2}" value="{!cnt}"/>
                </apex:commandButton>
                </apex:column>
           
                <apex:column headerValue="Entry">   
                <apex:outputText value="{!cnt}" />
               <apex:variable var="cnt" value="{!cnt+1}"/>       
                                       
                </apex:column>
       
        <apex:column headerValue="Date">
            <apex:inputField value="{!lnt.Date__c}"/>
        </apex:column>
        
        <apex:column headerValue="Client Code">
        <apex:inputField value="{!lnt.Client_Code__c}" />
        </apex:column>
        <apex:column width="100px" headerValue="Matter #">
        <apex:inputField value="{!lnt.Matter__c}" />
        </apex:column>
                
        <apex:column headerValue="Client Code -- Test">
   		<apex:selectList size="1" value="{!clientc}">
            <apex:selectoptions value="{!clientobj}"/>
            <apex:actionSupport event="onchange" reRender="MatterList"/>
            </apex:selectList>
          
         
        </apex:column>
        <apex:column width="100px" headerValue="Matter # -- Test">
        <apex:selectList size="1" value="{!matt}" id="MatterList">
            <apex:selectoptions value="{!mattobj}"/>
            <apex:actionSupport event="onchange" />
            </apex:selectList>
                         
 
        </apex:column>
         
        <apex:column width="100px" headerValue="Hours">
        <apex:inputField value="{!lnt.Hours_Worked__c}"  style="width: 100px"/>
        </apex:column>
        <apex:column width="100px" headerValue="Task">
        <apex:inputField value="{!lnt.Tasks__c}" style="width: 100px"/>
        </apex:column>          
        <apex:column width="1000px" headerValue="Narrative">
            <apex:inputField value="{!lnt.Narrative__c}" style="width: 1000px"/>
        </apex:column>
  
        
            </apex:pageblocktable>
      
            
        <apex:pageBlockButtons >
            <apex:commandbutton value="Add New Row" action="{!addTime}" rerender="thetable"/>
            <apex:commandButton value="Save Times" action="{!saveTime}"/>
            
            </apex:pageBlockButtons>
            </apex:pageblock>
             </td>
        </tr>
        </table>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 
I've created a small VF Page and Controller that exports Events pertaining to a specific Account.  The detailed link is on the Account Page and when clicked, passes the account.id to the Controller.  The Controller then references the EventRelation table and queries all the EventIDs to get all the Event Information and lists this on the Visual Force Page.  The VF page is set to automatically export into Excel.  

In my partial sandbox, all of the coding and testing works great.  The results are exactly what I'm expecting to get. 

However, when I deploy into production, I run into an issue.  It deploys perfectly and when I click the the detailed link on the Accounts Page, I get an error saying there are Zero Rows to select.  

I put in system.debugs to trace and also exported all EventRelations using Data Loader.  In my debug, I can see the EventID being referenced existing in the EventRelations table.  I've event copied the EventID and pasted into the browser and it took me to the correct event.  Ultimately, I'm trying to figure out why the query is returning zero results only in production.  

Any help is greatly appreciated!

Here is the controller code:
 
public class ActivitiesbyAccountController {

    public string idCurrentEvent {get;set;}
    Public Event evententry;
    Public List <EventRelation> eventconnect;
    Public List <Event> selected {get;set;}
    
    
    public ActivitiesbyAccountController(ApexPages.StandardController Account)
    {
        
        idCurrentEvent = ApexPages.currentPage().getParameters().get('id');
        system.debug(idCurrentEvent);
        
        selected=new list<Event>();
        
        eventconnect = [Select ID, relationid, eventid FROM EventRelation Where accountid = :idCurrentEvent];
        system.debug(eventconnect.size());
        system.debug(eventconnect);
        for(integer i=0;i<eventconnect.size();i++)
        {
         	system.debug('inside for loop');
            system.debug(i);
            system.debug(eventconnect.get(i).relationid +' ' + idCurrentEvent);
            if(eventconnect.get(i).relationid != idCurrentEvent)
       			  {
             		system.debug('inside if statement');
                      Event newevent = new Event();
          			string tempeventid = eventconnect.get(i).eventid;
					system.debug(tempeventid);            
          			newevent = [Select ID, OwnerID, subject, purpose_of_meeting__c, ActivityDate,WhatID From Event WHERE id = :tempeventid];
          			newevent.whoid = eventconnect.get(i).relationid;  
      				system.debug(newevent);
        			selected.add(newevent);  
        		 }
            
         }
     }
}


 
Hello All,

I have created a VisualForce page with a list that allows the end user to enter the values into the fields all at once.  At the end of each row, they have an option to add another row or to save all the data.  

In standard view, I have a verification rule on one of the Field X that makes sure if Field Y equals a specific value, then Field X cannot be Null.  This works great in the Standard view; however throws an exception error when entering through the VF list.  

I am not sure how to write a code for the VF list that verifies that Field X is not Null when Field Y equals a specific value.  Moreover, I have my list listNewTime and I do not know how to access the data temporarily being stored there prior to running the insert command.  

Thank you in advance.