@@ -24,4 +24,112 @@ Custom object for tracking sales orders.
2424
2525### [ Speaker__ c] ( custom-objects/Speaker__c.md )
2626
27- Represents a speaker at an event.
27+ Represents a speaker at an event.
28+
29+ ## Miscellaneous
30+
31+ ### [ BaseClass] ( miscellaneous/BaseClass.md )
32+
33+ ### [ MultiInheritanceClass] ( miscellaneous/MultiInheritanceClass.md )
34+
35+ ### [ ParentInterface] ( miscellaneous/ParentInterface.md )
36+
37+ ### [ ReferencedEnum] ( miscellaneous/ReferencedEnum.md )
38+
39+ ### [ SampleException] ( miscellaneous/SampleException.md )
40+
41+ This is a sample exception.
42+
43+ ### [ SampleInterface] ( miscellaneous/SampleInterface.md )
44+
45+ This is a sample interface
46+
47+ ### [ Url] ( miscellaneous/Url.md )
48+
49+ Represents a uniform resource locator (URL) and provides access to parts of the URL.
50+ Enables access to the base URL used to access your Salesforce org.
51+
52+ ## Usage
53+ Use the methods of the ` System.URL ` class to create links to objects in your organization. Such objects can be files, images,
54+ logos, or records that you want to include in external emails, in activities, or in Chatter posts. For example, you can create
55+ a link to a file uploaded as an attachment to a Chatter post by concatenating the Salesforce base URL with the file ID:
56+
57+ ``` apex
58+ // Get a file uploaded through Chatter.
59+ ContentDocument doc = [SELECT Id FROM ContentDocument
60+ WHERE Title = 'myfile'];
61+ // Create a link to the file.
62+ String fullFileURL = URL.getOrgDomainURL().toExternalForm() +
63+ '/' + doc.id;
64+ system.debug(fullFileURL);
65+ ```
66+
67+
68+ The following example creates a link to a Salesforce record. The full URL is created by concatenating the Salesforce base
69+ URL with the record ID.
70+
71+ ``` ape
72+ Account acct = [SELECT Id FROM Account WHERE Name = 'Acme' LIMIT 1];
73+ String fullRecordURL = URL.getOrgDomainURL().toExternalForm() + '/' + acct.Id;
74+ ```
75+
76+
77+ ## Example
78+ In this example, the base URL and the full request URL of the current Salesforce server instance are retrieved. Next, a URL
79+ pointing to a specific account object is created. Finally, components of the base and full URL are obtained. This example
80+ prints out all the results to the debug log output.
81+
82+ ``` apex
83+ // Create a new account called Acme that we will create a link for later.
84+ Account myAccount = new Account(Name='Acme');
85+ insert myAccount;
86+
87+ // Get the base URL.
88+ String sfdcBaseURL = URL.getOrgDomainURL().toExternalForm();
89+ System.debug('Base URL: ' + sfdcBaseURL );
90+
91+ // Get the URL for the current request.
92+ String currentRequestURL = URL.getCurrentRequestUrl().toExternalForm();
93+ System.debug('Current request URL: ' + currentRequestURL);
94+
95+ // Create the account URL from the base URL.
96+ String accountURL = URL.getOrgDomainURL().toExternalForm() +
97+ '/' + myAccount.Id;
98+ System.debug('URL of a particular account: ' + accountURL);
99+
100+ // Get some parts of the base URL.
101+ System.debug('Host: ' + URL.getOrgDomainURL().getHost());
102+ System.debug('Protocol: ' + URL.getOrgDomainURL().getProtocol());
103+
104+ // Get the query string of the current request.
105+ System.debug('Query: ' + URL.getCurrentRequestUrl().getQuery());
106+ ```
107+
108+
109+ ## Version Behavior Changes
110+ In API version 41.0 and later, Apex URL objects are represented by the java.net.URI type, not the java.net.URL type.
111+ The API version in which the URL object was instantiated determines the behavior of subsequent method calls to the
112+ specific instance. Salesforce strongly encourages you to use API 41.0 and later versions for fully RFC-compliant URL
113+ parsing that includes proper handling of edge cases of complex URL structures. API 41.0 and later versions also enforce
114+ that inputs are valid, RFC-compliant URL or URI strings.
115+
116+ * [ URL Constructors] ( https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_url.htm#apex_System_URL_constructors )
117+ * [ URL Methods] ( https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_url.htm#apex_System_URL_methods )
118+
119+ ** See Also**
120+ * [ URL Class] ( https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_url.htm )
121+
122+ ## Sample Enums
123+
124+ ### [ SampleEnum] ( sample-enums/SampleEnum.md )
125+
126+ This is a sample enum. This references [ ReferencedEnum] ( miscellaneous/ReferencedEnum.md ) .
127+
128+ This description has several lines
129+
130+ ## SampleGroup
131+
132+ ### [ SampleClass] ( samplegroup/SampleClass.md )
133+
134+ aliquip ex sunt officia ullamco anim deserunt magna aliquip nisi eiusmod in sit officia veniam ex
135+ deserunt ea officia exercitation laboris enim in duis quis enim eiusmod eu amet cupidatat.
0 commit comments