Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Using Apex, how can I determine a user's default landing URL - that is, the page that would be displayed when they first log in?

I'm trying to set up a page so that after performing an action via commandLink, they are redirected back as if they first logged in to Salesforce:

public PageReference setWhatever () {
    // do something
    if (result == true) {
        return new PageReference('/');  // ** What do I put here? **
    }
    return null;
}

I tried using PageReference('/'), but that sends them back to the login page, which is not my desired behavior. I can't just link to the homepage, though, because this needs to work in Customer Portal, and we're not exposing the home tab to all portals.

share|improve this question
add comment

1 Answer

If you really need to know the first page a specific user will be taken to, I'm not aware of a way to do that.

An approach that may be acceptable, which will obey the "flow laws" of Salesforce, is to make your controller an extension to the standard controller of the object the user is coming from, and then return the results of cancel() on the StandardController instance rather than figuring it out yourself.

This doesn't achieve exactly what you're looking for, but assuming the user is clicking the commandLink in the context of an object, it will at least take them back to whence they came.

If that doesn't work, you may have to resort to something like storing URL's in the database against user profiles or roles, or having a map of user license type to "home" page URL.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.