Go to URL action to logout from community

Hello!

I have created a button with a Go to URL action in order to logout from a community but I cannot have it working as expected:

  • if I use /secur/logout.jsp in the URL, I got an error since the /s is kept.
  • if I harcorde the full URL (…force.com/mycommunity/secur/logout.jsp), the logout works but is opened in a different windows even when the Open URL in option is set to the current windows.

Any ideas?

Many thanks!
Jesus

Try setting the URL to this:

{{$Site.Prefix}}/secure/logout.jsp

Thank you for your comment Zach. I am afraid the problem persists. With that URL the session remains active and a new windows is opened with an error.

Ah, you’re right, we’ve run into this as well, the {{$Site.Prefix}} includes a /s which is not correct for the logout URL.

So, a couple options, depending on how fancy you want to get:

  1. Hard-code the relative URL: /mycommunity/secur/logout.jsp
  2. Use a Ui-Only Model and a Formula Field to compute the relative URL dynamically so that you don’t have to hard-code the Community’s Prefix. And then use this in your URL.

Example: let’s say you create a Ui-Only Model called “PageVars” with a Formula Field called “LogoutUrl”, with the formula something like this, to strip off the leading “/s”:

RIGHT({{$Site.Prefix}},LEN({{$Site.Prefix}})-2) + “/secur/logout.jsp”

And then your URL would be: {{$Model.PageVars.data.0.LogoutUrl}}

Thank your for the suggestions Zach but these options have the problem of keeping the original windows still open with the session active (even when a new one is opened where the user is logged out).