• spenceSetGet
  • NEWBIE
  • 25 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 5
    Replies

I have created a visualforce page that is to show related bookings based on a Cruise Line Booking Number.  I only want this class to work if the Cruise Line Booking Number is populated. 

 

Current Class not working since no results are returned.  If I remove the If statement it works fine.  The problem is that is also shows bookings with no Cruise Line Booking Number.

 

public class VF_CruiseAdditionalPassengers {

	Cruise_Booking__c cb_vf;

	List<Cruise_Booking__c> rcb;
	
	public Cruise_Booking__c getCurrentCruise(){
    	if(cb_vf == null) cb_vf = [select Id, Name, Cruise_Line_Booking__c, Number_of_Passengers_del__c from Cruise_Booking__c where id= :ApexPages.currentPage().getParameters().get('id')];
    	
    	return cb_vf;
	}	


	public List<Cruise_Booking__c> getRelatedPassengers() {
		
		if(getCurrentCruise().Cruise_Line_Booking__c != '') {
		
			List<Cruise_Booking__c> rcb = [select Id, Name, Passenger__r.FirstName, Passenger__r.LastName , Passenger__r.Account.Name, Cruise_Balance__c, Number_of_Passengers_del__c, Cruise_Line_Booking__c 
											from Cruise_Booking__c WHERE Cruise_Line_Booking__c LIKE :getCurrentCruise().Cruise_Line_Booking__c ];			
		
		} else if(getCurrentCruise().Cruise_Line_Booking__c == '') {
			
			List<Cruise_Booking__c> rcb = NULL;
			
		}
		
		return rcb;
	
	}
	
}

 I'm new to Apex and this is my first VF page.  So this is a lot of guessing on my part to get this to work.

I have created a visualforce page that is to show related bookings based on a Cruise Line Booking Number.  I only want this class to work if the Cruise Line Booking Number is populated. 

 

Current Class not working since no results are returned.  If I remove the If statement it works fine.  The problem is that is also shows bookings with no Cruise Line Booking Number.

 

public class VF_CruiseAdditionalPassengers {

	Cruise_Booking__c cb_vf;

	List<Cruise_Booking__c> rcb;
	
	public Cruise_Booking__c getCurrentCruise(){
    	if(cb_vf == null) cb_vf = [select Id, Name, Cruise_Line_Booking__c, Number_of_Passengers_del__c from Cruise_Booking__c where id= :ApexPages.currentPage().getParameters().get('id')];
    	
    	return cb_vf;
	}	


	public List<Cruise_Booking__c> getRelatedPassengers() {
		
		if(getCurrentCruise().Cruise_Line_Booking__c != '') {
		
			List<Cruise_Booking__c> rcb = [select Id, Name, Passenger__r.FirstName, Passenger__r.LastName , Passenger__r.Account.Name, Cruise_Balance__c, Number_of_Passengers_del__c, Cruise_Line_Booking__c 
											from Cruise_Booking__c WHERE Cruise_Line_Booking__c LIKE :getCurrentCruise().Cruise_Line_Booking__c ];			
		
		} else if(getCurrentCruise().Cruise_Line_Booking__c == '') {
			
			List<Cruise_Booking__c> rcb = NULL;
			
		}
		
		return rcb;
	
	}
	
}

 I'm new to Apex and this is my first VF page.  So this is a lot of guessing on my part to get this to work.

I have a trigger that will update records that will sometimes cause the trigger to be fired a second time. I recall that there is a really easy way to determine if the current running trigger is already running but I can't recall the details. Can anyone help out? Thanks, Jon

I need help modifying a trigger I wrote.  The trigger is supposed to update the parent opportunity record everytime the child record, Media_Plan_History__c, is updated, which works correctly.  

 

I need to add a condition to the trigger so that the opportunity is only updated if a checkbox called Active__c is set to True on the Media_Plan_History__c record.  Where can I add this logic to the trigger?  I can't quite figure it out.

 

Thanks!

 

Here's my trigger:

 

trigger OppOwnerSH on Media_Plan_History__c (after update) {

 

Media_Plan_History__c[] shs;
shs = Trigger.new;

 

set<Id> oppIds = new Set <ID>();

 

for (Media_Plan_History__c sh : shs) {
    oppIds.add(sh.Opportunity__c);

 

Map<ID, Opportunity> oppsToUpdate = new Map<ID, Opportunity> (
    [select Id, Media_Planner_2__c from Opportunity
    where Id in :oppIds]);

 

List<Opportunity> oppUpd = new List<Opportunity>{};

 

for (Opportunity opp : oppsToUpdate.values()) {
    opp.media_planner_2__c = sh.media_planner_2__c;
    update opp;
    oppUpd.add(opp);

}

 

if (oppUpd != null && !oppUpd.isEmpty())
Database.update(oppUpd);
}
}

After editing my apex class from within the Force.com IDE, i clicked "Save" button. Got an error "File saved locally, not to server". How can i get past this errror? Thanks!