• Nathan A
  • NEWBIE
  • 25 Points
  • Member since 2010

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

I'm having a problem surrounding the use of:

 

 

ApexPages.currentPage().getHeaders().get('Host');

 

Wherein I'm making that call inside a Trigger deployed by my package on a Custom Object that's also inside my package, and when that resolves at runtime on the client's instance it still returns my developer's account URL rather than the client's instance URL.  Which makes about no sense at all.

 

How do I detect the URL of the instance that's actually running the code, rather than the URL of the instance where the code was developed originally?

I have an application that's been installed by one of my clients.  This application includes a Controller Extension that is defined as a global class.

 

I'd like the client to be able to create Visualforce Pages that use that custom Controller Extension.  Currently when they attempt to do this they get the following error:

 

 

	Error: Apex class 'LeadControllerExtension' does not exist

 

When attempting to create the following basic page:

 

 

<apex:page standardController="Lead" extensions="LeadControllerExtension" >
  <!-- Begin Default Content REMOVE THIS -->
  <h1>Congratulations</h1>
  This is your new Page
  <!-- End Default Content REMOVE THIS -->
</apex:page>

 

Any ideas?

 

 

Hi,

 

I'm currently trying to accomplish what should be a simple task.  I have a custom object that stores some configuration parameters in it for a Visualforce page.  

 

The Visualforce page has a Controller Extension defined that loads a custom configuration record based on an ID that's passed in on the URL to the controller.  The Visualforce page creates Leads.  Some of the fields on the Lead record need to be set to values that are found on the configuration record. 

 

When I attempt to set field values on the Lead record that comes in from the StandardController I keep getting the following error: System.NullPointerException: Attempt to de-reference a null object

 

I've tried to set the values on the Lead Record both in the constructor of my Controller Extension like this:

 

public with sharing class LeadControllerExtension {
    ApexPages.StandardController stdController;
    private final Web2LeadSettings__c settings;
    private Lead lead {get; set;}
    
    public LeadControllerExtension(ApexPages.StandardController c) {
        this.stdController = c;
        this.lead = (Lead)this.stdController.getRecord();
        this.lead.Web2LeadDeployment__c = this.settings.Web2LeadDeploymentName__c;
    	this.lead.LeadSource = this.settings.Web2LeadSource__c;
    }
    
    public Web2LeadSettings__c getSettings() {
    	return [select id, Web2LeadSource__c, Web2LeadDeploymentName__c, Web2LeadDeployedURL__c,
        				   Web2LeadForwardTo__c, Web2LeadDisplaySalesforceUI__c 
        				from Web2LeadSettings__c where name = :ApexPages.currentPage().getParameters().get('name')];
    }
}

 

 

and by attempting to override the save() method like this:

 

public with sharing class LeadControllerExtension {
    ApexPages.StandardController stdController;
    private final Web2LeadSettings__c settings;
    private Lead lead {get; set;}
    
    public LeadControllerExtension(ApexPages.StandardController c) {
        this.stdController = c;
        
    }
    
    public Web2LeadSettings__c getSettings() {
    	return [select id, Web2LeadSource__c, Web2LeadDeploymentName__c, Web2LeadDeployedURL__c,
        				   Web2LeadForwardTo__c, Web2LeadDisplaySalesforceUI__c 
        				from Web2LeadSettings__c where name = :ApexPages.currentPage().getParameters().get('name')];
    }
    
    public PageReference save() {
    	this.lead = (Lead)this.stdController.getRecord();
        this.lead.Web2LeadDeployment__c = this.settings.Web2LeadDeploymentName__c;
    	this.lead.LeadSource = this.settings.Web2LeadSource__c;
    	
    	this.stdController.save();
    	    	
    	return null;
    }
}

 

 

No matter what I try I can't seem to set the "lead" fields to values from my "settings" object.

 

Any ideas?

I have an application that's been installed by one of my clients.  This application includes a Controller Extension that is defined as a global class.

 

I'd like the client to be able to create Visualforce Pages that use that custom Controller Extension.  Currently when they attempt to do this they get the following error:

 

 

	Error: Apex class 'LeadControllerExtension' does not exist

 

When attempting to create the following basic page:

 

 

<apex:page standardController="Lead" extensions="LeadControllerExtension" >
  <!-- Begin Default Content REMOVE THIS -->
  <h1>Congratulations</h1>
  This is your new Page
  <!-- End Default Content REMOVE THIS -->
</apex:page>

 

Any ideas?