You need to sign in to do that
Don't have an account?
A
Problem with redirection of sites to different pages
Hi Friends,
please help me..its very urgent...
I have been trying to redirect site to the url given.
For example if we take salesforce if i give account details page url page and login with the credentials it goes to the particular account detail page, i want the same functionality in sites.
For that i have written the below code...its working for every page except the event detailpage( url is https://fulltest-future-leaders.cs30.force.com/FLIP/EventDetail?eid=a5H80000000Go61EAC&showComments=true&backUrl=/Events)
/**
* An apex page controller that exposes the site login functionality
*/
global class SiteLoginController {
//Properties to store username and password entered by the user
global String username {get; set;}
global String password {get; set;}
global String profileName {get; set;}
global String urlredirect {get; set;}
global String urlredirectSF {get; set;}
global String urlredirectSFbase {get; set;}
global SiteLoginController()
{
urlredirect= URL.getCurrentRequestUrl().toExternalForm();
urlredirectSF= URL.getSalesforceBaseUrl().toExternalForm();
urlredirectSFbase= string.valueof(URL.getSalesforceBaseUrl());
}
//Method to check the username and password. It will throw error if the username/password is incorrect
global PageReference login() {
//Setting profile Name
profileName = '';
//Setting start URL
String startUrl = '/apex/FLIPHome';
String flipredirect = '/apex/'+urlredirect.subStringAfter('FLIP/');
system.debug('----urlredirect----'+urlredirect);
system.debug('----urlredirectSF----'+urlredirectSF);
system.debug('----urlredirectSFbase----'+urlredirectSFbase);
// String eventurl ='apex/Eventdetails/'+urlredirect.subStringBetween('Events','&');
// String eventurl ='apex/Eventdetails/'+urlredirect.subStringAfter('/Events')+'showComments=true';
// String eventurl ='/apex/EventDetail/'+urlredirect.subStringAfter('FEvents');
// system.debug('----eventurl----'+eventurl);
// system.debug('----flipredirect----'+flipredirect);
//Query Profile Name
List<User> loginUser = [select ProfileId,username,Profile.Name from user where Username = :username];
if(loginUser.size()>0)
profileName = loginUser[0].Profile.Name;
system.debug('-------Profile Name--------'+ profileName);
if(profileName.equals('FLIP Participant') || profileName.equals('Readonly Participant'))
{
if(urlredirect.contains('LoginPage'))
{
system.debug('-------coming to login-------'+ urlredirect);
return Site.login(username, password, startUrl );
}
/* else if(urlredirect.contains('EventDetail'))
{
system.debug('-------coming to event-----'+ urlredirect);
return Site.login(username, password, eventurl );
} */
else { system.debug('value of startURL.....'+flipredirect);
return Site.login(username, password, flipredirect );
}
}
else if(profileName.equals('Executive Coach'))
{
startUrl = '/apex/MarketplaceHome';
return Site.login(username, password, startUrl );
}
else if(profileName.equals('LI Participant'))
{
startUrl = '/apex/LIHome';
return Site.login(username, password, startUrl );
}
else
return Site.login(username, password, startUrl);
}
}
Is there any problem with my code??????????
Or please suggest how can I navigate to a page based on URL....
Waiting for your help guys.......................
please help me..its very urgent...
I have been trying to redirect site to the url given.
For example if we take salesforce if i give account details page url page and login with the credentials it goes to the particular account detail page, i want the same functionality in sites.
For that i have written the below code...its working for every page except the event detailpage( url is https://fulltest-future-leaders.cs30.force.com/FLIP/EventDetail?eid=a5H80000000Go61EAC&showComments=true&backUrl=/Events)
/**
* An apex page controller that exposes the site login functionality
*/
global class SiteLoginController {
//Properties to store username and password entered by the user
global String username {get; set;}
global String password {get; set;}
global String profileName {get; set;}
global String urlredirect {get; set;}
global String urlredirectSF {get; set;}
global String urlredirectSFbase {get; set;}
global SiteLoginController()
{
urlredirect= URL.getCurrentRequestUrl().toExternalForm();
urlredirectSF= URL.getSalesforceBaseUrl().toExternalForm();
urlredirectSFbase= string.valueof(URL.getSalesforceBaseUrl());
}
//Method to check the username and password. It will throw error if the username/password is incorrect
global PageReference login() {
//Setting profile Name
profileName = '';
//Setting start URL
String startUrl = '/apex/FLIPHome';
String flipredirect = '/apex/'+urlredirect.subStringAfter('FLIP/');
system.debug('----urlredirect----'+urlredirect);
system.debug('----urlredirectSF----'+urlredirectSF);
system.debug('----urlredirectSFbase----'+urlredirectSFbase);
// String eventurl ='apex/Eventdetails/'+urlredirect.subStringBetween('Events','&');
// String eventurl ='apex/Eventdetails/'+urlredirect.subStringAfter('/Events')+'showComments=true';
// String eventurl ='/apex/EventDetail/'+urlredirect.subStringAfter('FEvents');
// system.debug('----eventurl----'+eventurl);
// system.debug('----flipredirect----'+flipredirect);
//Query Profile Name
List<User> loginUser = [select ProfileId,username,Profile.Name from user where Username = :username];
if(loginUser.size()>0)
profileName = loginUser[0].Profile.Name;
system.debug('-------Profile Name--------'+ profileName);
if(profileName.equals('FLIP Participant') || profileName.equals('Readonly Participant'))
{
if(urlredirect.contains('LoginPage'))
{
system.debug('-------coming to login-------'+ urlredirect);
return Site.login(username, password, startUrl );
}
/* else if(urlredirect.contains('EventDetail'))
{
system.debug('-------coming to event-----'+ urlredirect);
return Site.login(username, password, eventurl );
} */
else { system.debug('value of startURL.....'+flipredirect);
return Site.login(username, password, flipredirect );
}
}
else if(profileName.equals('Executive Coach'))
{
startUrl = '/apex/MarketplaceHome';
return Site.login(username, password, startUrl );
}
else if(profileName.equals('LI Participant'))
{
startUrl = '/apex/LIHome';
return Site.login(username, password, startUrl );
}
else
return Site.login(username, password, startUrl);
}
}
Is there any problem with my code??????????
Or please suggest how can I navigate to a page based on URL....
Waiting for your help guys.......................
Try it out.
Site s = [SELECT s.Subdomain FROM Site s LIMIT 1 ];
String urlCode = String.valueof(URL.getSalesforceBaseUrl().toExternalForm());
String [] cuts = urlCode.split('[.]');
urlCode = '';
for(Integer i = 1; i < cuts.size(); i++){
if(!cuts[i].contains('visual')){
urlCode += cuts[i] + '.';
}
}
urlCode = urlCode.substring(0, urlCode.length()-1);
urlCode = 'https://'+s.Subdomain+'.'+urlCode+'/yourpage;
Also see the below links with more information and related threads,
https://developer.salesforce.com/forums?id=906F00000008w9wIAA
http://salesforce.stackexchange.com/questions/7639/get-site-url-from-apex
Also, Vote for this Idea,
https://success.salesforce.com/ideaView?id=08730000000kvysAAA
Regards,
Ashish