+ Start a Discussion
maxoutmaxout 

Getting Site URL from within trigger

Hi there,

It is to get user's org server/domain.

Trying Site.getCurrentSiteUrl, but it returns null.

In the context of trigger, there seems to be limitations.

Any idea appriciated.

 

Related:

http://boards.developerforce.com/t5/General-Development/Getting-Site-URL/m-p/109559

maxoutmaxout

This works:

Cookie counter=new Cookie('NoneObject', '0',null,-1,false);
string=counter.getDomain();

 

However, wondering what is the best practise.

Shashikant SharmaShashikant Sharma

The event that takes you in trigger is taking place from where? Any site page acceses from guest user profile?or you have logged in as internal user and performing event that invokes a trigger?

Rahul S.ax961Rahul S.ax961

Try This :) ,

 

String ServerUrl =  'https://'+ApexPages.currentPage().getHeaders().get('Host');
system.debug(ServerUrl);

 

 

Ritesh AswaneyRitesh Aswaney

As part of Summer 11, there is now a System.URL class which should let you grab your instance URL using URL.getSalesforceBaseUrl()

 

http://developer.force.com/releases/release/Summer11/System+URL+Class

maxoutmaxout

The event is a normal save action from the web UI, instead of a background process.

Thanks to you alll.