You need to sign in to do that
Don't have an account?
Ramk123
Apex logic help to switch communities
Dear Experts,
I would like to switch community with the apex logic.
SELECT GuestUserId, Name, Subdomain, UrlPathPrefix FROM Site 'abc'
If UrlPathPrefix is abc
returnurl = '/abc' + returnurl
else if UrlPathPrefix is xyz
returnurl = '/xyz' + returnurl
anyone please help me to frame the logic to return proper community URL.
I would like to switch community with the apex logic.
SELECT GuestUserId, Name, Subdomain, UrlPathPrefix FROM Site 'abc'
If UrlPathPrefix is abc
returnurl = '/abc' + returnurl
else if UrlPathPrefix is xyz
returnurl = '/xyz' + returnurl
anyone please help me to frame the logic to return proper community URL.
Using Network.getLoginUrl('Pass Community id here') you can get the login page URL for the community and then break the URL and use it as per requirement.
Related: https://salesforce.stackexchange.com/questions/55506/how-can-i-get-my-community-base-url-in-apex
If this information helps, please mark the answer as best.Thank you
Posting sample code here for your reference
NOTE: The code provided is an example. You'll need to review and make modifications for your organization.
Let me know if this helps, if it does, please mark this answer as best so that others facing the same issue will find this information useful. Thank you