0

I would like to get the getLoginUrl information of a Network sObject.
what is the be way to get this information dynamically via SOQL? since static methods can't be invoked dynamically.

Thanks

2 Answers 2

0

The UrlPathPrefix field (name of the community that's appended to the network path to reach its home page) can be queried from the Network Object. See the Object Reference for more on what can be queried on a Community Network.

If the log-in page has been overridden, you'd also want to query the NetworkPageOverride object. You should be able to combine these into a single query using a subquery to obtain both to obtain any override settings. Querying the latter requires the network's Id and I don't think you'd want to run two queries if you can avoid it.

2
  • I tried to query the UrlPathPrefix field from the Network object but I see that it is empty. @crmprogdev Do you have a suggestion?
    – nirp
    Nov 1, 2015 at 14:49
  • You might want to query the Status field too to see if it's Live, Down for Maint, or Under Construction plus try OptionsShowAllNetworkSettings (show or hide config data). That being said, from the object ref: "If you have “Modify All Data,” “View All Data,” or “Create and Set Up Communities,” you can view all communities in the organization. Users without these permissions only see the Preview or Published communities that they’re members of." I don't know of anything else that's likely to help you directly replace get('startURL') if that's what you're looking for.
    – crmprogdev
    Nov 1, 2015 at 15:12
0

For anyone searching yet for a solution:

String networkId = [SELECT Id FROM Network WHERE Name = 'COMMUNITY_NAME']?.Id; // (extra point) using Safe Navigation Operator (?.)
System.debug('Community login url: ' + System.Network.getLoginUrl(networkId));

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .