What is Platform Cache?
| Type | Description |
|---|---|
| Org Cache | Shared across all users in the org; used for commonly accessed data |
| Session Cache | Unique per user session (browser or API session); used for session-specific data |
| Type | Description |
|---|---|
| Org Cache | Shared across all users in the org; used for commonly accessed data |
| Session Cache | Unique per user session (browser or API session); used for session-specific data |
Salesforce Integration Target Vs Source
Target Screen1: Manage Connected Apps
Step:1
Endpoint Details
@RestResource(urlMapping='/receiveAccount/*')
global class OrgB_AccountReceiver {
@HttpPost
global static String
receiveAccount() {
RestRequest req =
RestContext.request;
String requestBody =
req.requestBody.toString();
System.debug('Received body: '
+ requestBody);
try {
Account acc = (Account)
JSON.deserialize(requestBody, Account.class);
// Clear ID if present to
avoid insert error
acc.Id = null;
insert acc;
return 'Account inserted:
' + acc.Id;
} catch (Exception e) {
return JSON.serialize(new
Map<String, Object>{
'errorCode' =>
'APEX_ERROR',
'message' =>
e.getMessage()
});
}
}
}
Step 1: Navigate to Auth. Providers
Step 2: Configure Auth. Provider Details
In the New
Auth. Provider screen, set the following fields:
|
Field |
Value |
|
Provider
Type |
Salesforce |
|
Name |
SSO From Partner Org (or any name you choose) |
|
URL
Suffix |
Auto-filled
(can be customized, e.g., SalesforceSSO) |
|
Consumer
Key |
(Copy
from the Connected App in the other org — explained below) |
|
Consumer
Secret |
(From
the same Connected App as above) |
|
Authorize
Endpoint URL |
https://login.salesforce.com/services/oauth2/authorize |
|
Token
Endpoint URL |
https://login.salesforce.com/services/oauth2/token |
|
User
Info Endpoint URL |
https://login.salesforce.com/services/oauth2/userinfo |
|
Default
Scopes |
openid profile email or leave blank |
|
Registration
Handler |
Create
or select a registration handler Apex class (explained below) |
|
Execute
Registration As |
Select
an admin user |
|
Icon
URL |
(Optional) |
|
Custom
Logout URL |
(Optional) |
Click Save.
Step 3: Copy Callback URL
After
saving, Salesforce generates a Callback URL (e.g.,
https://yourDomain.my.salesforce.com/services/authcallback/SalesforceSSO).
Create Named Credential (Target Org)
Step 1: Navigate to Named Credentials
Step:2
Step:3
Step:4
To send Account record data from Salesforce Org A to Salesforce
Org B using:
public class AccountSync {
@future(callout=true)
public static void sendToOrgB(Id
accId) {
Account acc = [SELECT Id,
Name, Phone, Website, Email__c FROM Account WHERE Id = :accId LIMIT 1];
HttpRequest req = new
HttpRequest();
req.setEndpoint('callout:OrgB_API/services/apexrest/receiveAccount/');
req.setMethod('POST');
req.setHeader('Content-Type',
'application/json');
req.setHeader('Accept',
'application/json');
req.setBody(JSON.serialize(acc));
req.setTimeout(120000);
Http http = new Http();
try {
HttpResponse res =
http.send(req);
System.debug('Org B
Response: ' + res.getBody());
} catch(Exception e) {
System.debug('Error
sending Account to Org B: ' + e.getMessage());
}
}
}
Source Org :-
Target :-
Account data submitted in Salesforce → Sent to External API → Account created in the external system → External System ID stored in Salesforce.
Explanation of Log Content:
Console.log:
Used for frontend debugging in JavaScript or Lightning Web Components (LWC).
Logs messages, variables, and errors to the browser console.
HRA.log:
A custom log file for a Human Resources Application.
Tracks application events, warnings, and errors for auditing and debugging purposes.
Apexdebug.log:
Generated by Salesforce for debugging Apex code.
Captures execution details, SOQL queries, debug statements, and exceptions.
These logs are essential for troubleshooting, monitoring, and improving applications. The content and structure will vary depending on the specific use case and the system being debugged.
Understanding Logs: Console.log, HRA.log, and Apex Debug.log
1. User Submits Account Form
The user enters Name, Email, and Phone in a Lightning Web Component (LWC).
Clicking Submit triggers a call to an Apex method (sendAccountData).
2. Data Sent to External API
The Apex method sends account details to an external system via an API request.
The external system creates a new account and returns a unique External System ID.
3. Account Created in Salesforce
A new Account record is inserted in Salesforce.
The response from the external system is processed:
If an id is received, it is stored in the External_Id__c field on the Salesforce Account.
If no ID is returned, an appropriate message is stored.
4. Two-Way Synchronization Achieved
Salesforce and the external system are now linked via the External System ID.
Future updates can be synchronized based on this ID for real-time integration.