Skip to content

forcedotcom/sf-skills / plugins/builder/salesforce-development/skills/platform-sharing-owd-configure

platform-sharing-owd-configure

Verified

Use when the user wants to retrieve or update Organization-Wide Default (OWD) sharing settings for Salesforce objects. TRIGGER on org-wide defaults, checking/viewing sharing defaults, changing default access levels (Private, Public Read Only, Public Read/Write, Controlled by Parent), internal/external access for standard or custom objects, making records private, or sharingModel in .object-meta.xml files. DO NOT TRIGGER for sharing rules, criteria-based sharing, role hierarchy, or manual sharing — delegate to platform-sharing-rules-generate.

references/metadata_api_approach.md

View on GitHub
# Metadata API Approach for Updating OWD

When the Tooling API approach is not suitable or the user prefers a metadata-driven workflow, use the Metadata API to update Organization-Wide Defaults.

## Step-by-Step Procedure

### 1. Create a project directory (if not already in an SFDX project)

```bash
sf project generate --name owd-update --template empty
cd owd-update
```

### 2. Retrieve the object metadata

Both standard and custom objects store their OWD sharing model in `<Object>.object-meta.xml` using the `<sharingModel>` and `<externalSharingModel>` elements.

```bash
sf project retrieve start --metadata CustomObject:<ObjectName> --target-org <org>
```

This creates a file at: `force-app/main/default/objects/<ObjectName>/<ObjectName>.object-meta.xml`

### 3. Locate the sharing model entries

The object metadata file contains `<sharingModel>` and `<externalSharingModel>` elements:

Example for a standard object (Account):
```xml
<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
    <sharingModel>ReadWrite</sharingModel>
    <externalSharingModel>Private</externalSharingModel>
</CustomObject>
```

Example for a custom object (Invoice__c):
```xml
<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
    <label>Invoice</label>
    <sharingModel>Private</sharingModel>
    <externalSharingModel>Private</externalSharingModel>
</CustomObject>
```

### 4. Modify the sharing model values

Update the `<sharingModel>` (internal access) and/or `<externalSharingModel>` (external access) to the desired access level. See `access_levels.md` for valid values per object.

### 5. Deploy the changes

```bash
sf project deploy start --metadata CustomObject:<ObjectName> --target-org <org>
```

### 6. Verify

Re-query using the Tooling API to confirm the change took effect:
```bash
sf data query --query "SELECT QualifiedApiName, InternalSharingModel, ExternalSharingModel FROM EntityDefinition WHERE QualifiedApiName = '<ObjectName>'" --use-tooling-api --target-org <org>
```

## When to Use This Approach

- User wants a source-trackable, version-controlled change
- Multiple OWD changes need to be deployed together
- Change is part of a larger metadata deployment
- Tooling API direct update is not permitted by org policies
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall