Salesforce video on OWD sharing settings, custom settings, metadata
Here is the video-ready package for “Salesforce — OWD, Sharing Rules, Custom Settings & Metadata (with code)”. It contains a tight video outline, speak-as-you-record script, slide text, demo steps, and copy-pasteable code (Apex + metadata + SFDX commands). Use this as your shot-by-shot guide.
Video title (suggested)
Salesforce OWD, Sharing Rules, Custom Settings & Metadata — Complete Guide (with Code)
1 — Short video outline (ideal ~8–12 min)
- Intro (0:00–0:20) — what you'll cover
- OWD basics (0:20–1:30) — purpose & examples
- Sharing Rules (1:30–3:00) — owner vs criteria-based + demo
- Custom Settings (3:00–4:30) — List vs Hierarchy + Apex examples
- Manual Sharing via Apex (4:30–5:30) — why & how
- Custom Metadata vs Custom Settings (5:30–6:30) — deployability & use-cases
- Metadata & SFDX (6:30–8:00) — retrieve/deploy sharing metadata
- Wrap & best practices (8:00–8:30)
2 — Shot-by-shot script (readable, short lines)
Intro:
“Hi — today we’ll cover OWD, Sharing Rules, Custom Settings and Metadata in Salesforce, and I’ll show working Apex and SFDX commands so you can reproduce everything in a sandbox.”
OWD:
“Organization-Wide Defaults set the baseline: Private, Public Read Only, or Public Read/Write. Always start secure — set most restrictive and open via sharing.”
Sharing Rules:
“Sharing rules expand access. Owner-based shares are by owner’s role or group. Criteria-based use field values — great for business logic.”
Custom Settings:
“List custom settings hold repeating config rows; Hierarchy settings allow profile/user overrides. They’re fast and accessible in Apex.”
Manual shares:
“Manual shares are for edge cases or when declarative sharing can’t handle an access requirement — carefully maintain them.”
Metadata:
“Use Metadata API/SFDX to retrieve and deploy SharingRules and SharingSettings. For production, prefer metadata-driven approaches.”
Wrap:
“Test with ‘Login As’, document RowCause values for manual shares, and prefer criteria rules over manual shares when possible.”
3 — On-screen slide text (copy/paste)
- “OWD = baseline access: Private | Public Read Only | Public Read/Write”
- “Sharing Rules: Owner-based ▪ Criteria-based”
- “Custom Settings: List ▪ Hierarchy — fast Apex access”
- “Manual Sharing: Insert <Object>Share record (RowCause = Manual)”
- “Metadata: Retrieve SharingRules & SharingSettings via SFDX/MDAPI”
4 — Demo steps (what to record)
- Setup → Security → Sharing Settings: show OWD values.
- Create a Public Group.
- Create a Criteria-based Sharing Rule (e.g.,
Project__cwherePriority__c = 'High'share Read to your Public Group). - Create List and Hierarchy Custom Settings; add sample rows.
- Execute Anonymous: read custom settings values in Apex and show debug.
- Execute Anonymous: insert a manual share (
MyCustom__ShareorAccountShare), show receiving user’s access via “Login As”. - Use SFDX to retrieve sharing metadata and show the resulting XML files.
5 — Copy-pasteable Code Snippets
A) Apex — Read Hierarchy Custom Setting
// Hierarchy Custom Setting: OrgConfig__c with field: Default_Expiry_Hours__c (Number)
OrgConfig__c cfg = OrgConfig__c.getOrgDefaults();
System.debug('Org-level expiry hours: ' + cfg.Default_Expiry_Hours__c);
// User-level override example
OrgConfig__c userCfg = OrgConfig__c.getInstance(UserInfo.getUserId());
System.debug('User-level expiry hours: ' + (userCfg != null ? userCfg.Default_Expiry_Hours__c : 'no override'));
JavaScriptB) Apex — Read List Custom Setting
// List Custom Setting: FeatureToggle__c (Name is key, field: Is_Enabled__c)
Map<String, FeatureToggle__c> toggles = FeatureToggle__c.getAll();
for (FeatureToggle__c ft : toggles.values()) {
System.debug('Feature: ' + ft.Name + ' => Enabled: ' + ft.Is_Enabled__c);
}
FeatureToggle__c single = FeatureToggle__c.getValues('NewUI');
System.debug('NewUI enabled? ' + (single != null ? single.Is_Enabled__c : 'not found'));
JavaScriptC) Apex — Manual Sharing (Custom Object example)
// Custom object API name: Project__c -> share object: Project__Share
Id projectId = 'a0BXXXXXXXXXXXX'; // replace with record id
Id groupId = '00GXXXXXXXXXXXX'; // public group or queue id
Project__Share ps = new Project__Share();
ps.ParentId = projectId;
ps.UserOrGroupId = groupId;
ps.AccessLevel = 'Read'; // 'Read' or 'Edit'
ps.RowCause = Schema.Project__Share.RowCause.Manual;
insert ps;
System.debug('Inserted Project__Share id: ' + ps.Id);
JavaScriptD) Apex — Manual Sharing (Account example)
Id acctId = '001XXXXXXXXXXXX';
Id userOrGroupId = '005XXXXXXXXXXXX'; // Could be user or group Id
AccountShare ash = new AccountShare();
ash.AccountId = acctId;
ash.UserOrGroupId = userOrGroupId;
ash.AccountAccessLevel = 'Read'; // or 'Edit'
ash.RowCause = Schema.AccountShare.RowCause.Manual;
insert ash;
JavaScriptNote: Use correct
RowCauseconstant for your use-case.Manualis common when adding shares via UI or Apex.
6 — Metadata examples (deployable XML)
A) sharingRules metadata (criteria-based example for custom object Project__c)
<?xml version="1.0" encoding="UTF-8"?>
<SharingRules xmlns="http://soap.sforce.com/2006/04/metadata">
<criteriaBasedSharingRules>
<fullName>Project_HighPriority_to_Team</fullName>
<accessLevel>Read</accessLevel>
<description>Share high priority projects to Support Team</description>
<booleanFilter>1</booleanFilter>
<criteriaItems>
<field>Priority__c</field>
<operation>equals</operation>
<value>High</value>
</criteriaItems>
<sharedTo>00Gxxxxxxxxxxxx</sharedTo> <!-- public group Id placeholder -->
<shareTo>Group</shareTo>
</criteriaBasedSharingRules>
</SharingRules>
JavaScriptB) sharingSettings (org default snippet for a custom object)
<?xml version="1.0" encoding="UTF-8"?><br><SharingSettings xmlns="http://soap.sforce.com/2006/04/metadata"><br> <customObjectSharingRules><br> <!-- custom object rules placed here --><br> </customObjectSharingRules><br> <defaultSettings><br> <object>Project__c</object><br> <defaultInternalAccess>Private</defaultInternalAccess><br> <defaultExternalAccess>Private</defaultExternalAccess><br> </defaultSettings><br></SharingSettings><br>JavaScriptTip: Actual
SharingSettingsstructure varies by API version — retrieve from the org to get the correct format for your org.
7 — Custom Metadata Type example (deployable)
Custom Metadata type: AppConfig__mdt with field Default_Expiry_Hours__c
Custom Metadata record (XML)
<?xml version="1.0" encoding="UTF-8"?>
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata">
<label>Default App Config</label>
<protected>false</protected>
<values>
<field>Default_Expiry_Hours__c</field>
<value>24</value>
</values>
</CustomMetadata>
JavaScript8 — SFDX / MDAPI commands (retrieve & deploy)
package.xml (include types you need)
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types><members>*</members><name>SharingRules</name></types>
<types><members>*</members><name>SharingSettings</name></types>
<types><members>*</members><name>CustomObject</name></types>
<types><members>*</members><name>CustomMetadata</name></types>
<version>57.0</version>
</Package>
JavaScriptRetrieve (mdapi)
# Authenticate first: sfdx auth:web:login -a MySandbox
sfdx force:mdapi:retrieve -s -r ./mdapi_out -k ./package.xml -u MySandbox
unzip -q mdapi_out/unpackaged.zip -d mdapi_out/unpackaged
JavaScriptOr source:retrieve (source-tracked org)
sfdx force:source:retrieve -m SharingSettings,SharingRules,CustomMetadata -u MySandbox
JavaScriptDeploy
sfdx force:mdapi:deploy -d ./mdapi_out/unpackaged -u MySandbox --wait 10 --checkonly=false
JavaScript9 — Quick testing checklist (record these steps)
- Use a sandbox for changes.
- Create test users in different roles/profiles.
- Use “Login As” to verify access after sharing rules/manual share.
- Run Apex in Execute Anonymous and inspect debug logs.
- Retrieve metadata after creating rules to show the exact XML that will deploy.
10 — Best practices to call out (short)
- Always prefer restrictive OWD + sharing rules vs. loosening OWD.
- Use criteria-based sharing rules for scalable access.
- Prefer Custom Metadata over Custom Settings for deployable config.
- Document manual
RowCausevalues and who creates manual shares. - Test thoroughly with different user contexts.
Related Posts

How to Automatically create a follow-up Task when a Lead is converted

How You need to update a related child record whenever a parent record’s status changes, but only if the status is “Closed Won.” How would you design this in Apex?
