I have created an apex class as per your requirement.
public class SiteId {
public static void getSideId(){
String siteId = Site.getSiteId();
Site site = [SELECT GuestUserId, Name, Subdomain, UrlPathPrefix FROM Site WHERE id = : siteId];
}
}
You can get the secureURL using the SiteDetail object:
Site mySite = [select Id from Site where Name = 'MySite'];
SiteDetail mySiteDetail = [select SecureURL from SiteDetail where DurableId = :mySite.Id];
System.debug(mySiteDetail.SecureURL);
Please refer to the below link which might help you further with the above requirement.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
I have created an apex class as per your requirement.
public class SiteId {
public static void getSideId(){
String siteId = Site.getSiteId();
Site site = [SELECT GuestUserId, Name, Subdomain, UrlPathPrefix FROM Site WHERE id = : siteId];
}
}
To retrieve details about the current site, you can query the `Site` object based on the site's ID. Here's an example:
```apex String siteId = Site.getSiteId(); Site currentSite = [SELECT Id, Name, Subdomain, UrlPathPrefix FROM Site WHERE Id = :siteId LIMIT 1]; System.debug('Current Site Name: ' + currentSite.Name); System.debug('Current Site Subdomain: ' + currentSite.Subdomain); System.debug('Current Site URL Path Prefix: ' + currentSite.UrlPathPrefix); ```
Remember to handle potential exceptions that might occur, such as if the `Site` object is not available or if the query doesn't return any results.
Please note that to use this code, you need to have the necessary permissions and context to access the `Site (https://www.capcutgeeks.com/)` object. Also, make sure you are working in the appropriate context, such as a Visualforce page or a trigger, where the `Site` object and related methods are available.
You can use the below code and links:
I have created an apex class as per your requirement.
Links:
1.https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_sites.htm.
2.https://salesforce.stackexchange.com/questions/7639/get-site-url-from-apex.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com
All Answers
Greetings to you!
You can query the Id like this:
https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_site.htm
https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_sitedetail.htm
You can get the secureURL using the SiteDetail object:
Please refer to the below link which might help you further with the above requirement.
https://salesforce.stackexchange.com/questions/7639/get-site-url-from-apex
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
You can use the below code and links:
I have created an apex class as per your requirement.
Links:
1.https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_sites.htm.
2.https://salesforce.stackexchange.com/questions/7639/get-site-url-from-apex.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com
1. **Retrieve Current Site ID:**
You can get the current site's ID using the `Site.getSiteId()` method. Here's an example:
```apex
String siteId = Site.getSiteId();
System.debug('Current Site ID: ' + siteId);
```
2. **Retrieve Current Site Details:**
To retrieve details about the current site, you can query the `Site` object based on the site's ID. Here's an example:
```apex
String siteId = Site.getSiteId();
Site currentSite = [SELECT Id, Name, Subdomain, UrlPathPrefix FROM Site WHERE Id = :siteId LIMIT 1];
System.debug('Current Site Name: ' + currentSite.Name);
System.debug('Current Site Subdomain: ' + currentSite.Subdomain);
System.debug('Current Site URL Path Prefix: ' + currentSite.UrlPathPrefix);
```
Remember to handle potential exceptions that might occur, such as if the `Site` object is not available or if the query doesn't return any results.
Please note that to use this code, you need to have the necessary permissions and context to access the `Site (https://www.capcutgeeks.com/)` object. Also, make sure you are working in the appropriate context, such as a Visualforce page or a trigger, where the `Site` object and related methods are available.