You need to sign in to do that
Don't have an account?
trying to return the url/instance (and map it from c.cso.visual.force to tapp0.salesforce)
I had created a controller extension code that works fine in sandbox, but when I am running test against the controller code, it would fail with the generic error message:
System.NullPointerException: Attempt to de-reference a null object
Specifically, I needed a way to simulate what the detailed link of an object is but since we can't select that from visualforce page, I was trying to use the following code:
PageReference FSLpage = new PageReference('/'+FSL.id); // this returns the id of the custom object entry.
string hostname = ApexPages.CurrentPage().getHeaders().get('Host'); // this would return c.cs0.visual.force
host = host.replace('c.cs0.visual.force','tapp0.salesforce');
FSL_Link = 'https://"+host+FSLpage.getURL();
and this would return the appropriate value when the visualforce page is invoked so that instead of
something like:
https://c.cs0.visual.force.com/xxxxxyyyzzz
it would return
https://tapp0.salesforce.com/xxxxxxyyyzzz
However when running unit testing on this controller extension, it would fail - even though it looks like it runs fine. So how can i fix this so that I can actually deploy this to our production or make sure the test doesn't fail?