• Mike Cerruti
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
I need to create a test class for this controller.  It is fairly simple but I don't know where to start.

The conroller is used in a Visualforce page in it's simplist form:
<apex:page controller="TravelDetailController" readOnly="true">
<p>Here are all the Booked Travel Details:</p>
<table>
<apex:dataTable value="{!AllDetails}" var="detail">
<tr>
    <td border="2">
    <apex:Column>
        <apex:facet name="header">TDR</apex:facet>
        <apex:outputText value="{!detail.Name}" />
    </apex:Column>
    </td>
    <td>
    <apex:Column>
        <apex:facet name="Flight Status">Flight Status</apex:facet>
        <apex:outputText value="{!detail.Flight_Status__c}" />
    </apex:Column>
    </td>
    </tr>  
</apex:dataTable>
</table>
</apex:page>

Controller
public class TravelDetailController {
    public List<Travel_Detail__c> getAllDetails(){
        List<Travel_Detail__c> theDetails =
            [SELECT Name,
                 Flight_Status__c,
                 Traveler__c,
                 Connecting_Flight__c,
                 Flight_Departure_Date_Time_Local__c,
                 Flight_Booked_Departure_Time__c,
                 Flt_Dep__c,
                 Flt_Arv__c,
                 Flight_Arrival_City__c,
                 Flight_Booked_Arrival_Time__c,
                 Travel_Vendor__r.Name,
                 Flight__c,
                 Confirmation__c,
                 Travel_Detail_Type__c,
                 Detail_Status__c
             FROM Travel_Detail__c
             WHERE Detail_Status__c = 'Booked'];
        Return(theDetails);
    }
}

Any help would be appreciated.
 
I'm trying to create a class and method that will update a field on a record when a picklist value is changed.  I get the Too many SOQL queries error.

It is called by the following trigger:

trigger triggerUpdateTravelChange on Travel_Detail__c (after update, before update) {
    Travel_Detail__c[] travel_details = Trigger.new;
    If(Trigger.Isafter){
        //Updates the Change Travel Ticket Date and 
        //Increments the Change Travel Ticket Revision
        //on the Travel Ticket
        UpdateTravelChange.findTravelDetail(travel_details);
        updateTravelDetailStatus.updateTravelTicket(travel_details);

//TravelCalendarUpdate.TravelDetail(travel_details);

    }
    If(Trigger.Isbefore){
        //Updates the Change Revision and Change Date Fields
        // on the Travel Detail Record
        TravelDetailBooked.updateBooked(travel_details);
    }
}

Apex Class

trigger triggerUpdateTravelChange on Travel_Detail__c (after update, before update) {
    Travel_Detail__c[] travel_details = Trigger.new;
    If(Trigger.Isafter){
        //Updates the Change Travel Ticket Date and 
        //Increments the Change Travel Ticket Revision
        //on the Travel Ticket
        UpdateTravelChange.findTravelDetail(travel_details);
        updateTravelDetailStatus.updateTravelTicket(travel_details);

//TravelCalendarUpdate.TravelDetail(travel_details);

    }
    If(Trigger.Isbefore){
        //Updates the Change Revision and Change Date Fields
        // on the Travel Detail Record
        TravelDetailBooked.updateBooked(travel_details);
    }
}
I'm trying to create a class and method that will update a field on a record when a picklist value is changed.  I get the Too many SOQL queries error.

It is called by the following trigger:

trigger triggerUpdateTravelChange on Travel_Detail__c (after update, before update) {
    Travel_Detail__c[] travel_details = Trigger.new;
    If(Trigger.Isafter){
        //Updates the Change Travel Ticket Date and 
        //Increments the Change Travel Ticket Revision
        //on the Travel Ticket
        UpdateTravelChange.findTravelDetail(travel_details);
        updateTravelDetailStatus.updateTravelTicket(travel_details);

//TravelCalendarUpdate.TravelDetail(travel_details);

    }
    If(Trigger.Isbefore){
        //Updates the Change Revision and Change Date Fields
        // on the Travel Detail Record
        TravelDetailBooked.updateBooked(travel_details);
    }
}

Apex Class

trigger triggerUpdateTravelChange on Travel_Detail__c (after update, before update) {
    Travel_Detail__c[] travel_details = Trigger.new;
    If(Trigger.Isafter){
        //Updates the Change Travel Ticket Date and 
        //Increments the Change Travel Ticket Revision
        //on the Travel Ticket
        UpdateTravelChange.findTravelDetail(travel_details);
        updateTravelDetailStatus.updateTravelTicket(travel_details);

//TravelCalendarUpdate.TravelDetail(travel_details);

    }
    If(Trigger.Isbefore){
        //Updates the Change Revision and Change Date Fields
        // on the Travel Detail Record
        TravelDetailBooked.updateBooked(travel_details);
    }
}