Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

Can OWD be imported/exported as metadata?

Asked by Bhagwati Dubey Jul 10, 2021 3.0K views 2 answers
Share

About this question

 I'm currently trying to create a scratch org which reflects our ludicrously complicated production org which contains hundreds of Roles.

Upon deploying most of these, I get errors like:

Error src/roles/WhateverUser.role WMSportCustomerUser field integrity exception: unknown (Opportunity access level below organization default) I guess this means I need to correctly configure the OWD before these roles can be deployed. Is there any way to do this using metadata (preferably "mdapi" since we aren't ready to move to "source" yet)? Don’t know how to import OWD as metadata?

Your answer

2 Answers

Ranjana Admin JanBask Expert Latest answer

Answered on May 29, 2024

Yes, Organization-Wide Defaults (OWD) settings can be imported and exported as metadata in Salesforce. OWD settings are part of the security settings that can be managed through the Metadata API, which allows you to deploy and retrieve metadata components.

Exporting OWD as Metadata

To export OWD settings, you need to retrieve the relevant metadata using the Salesforce Metadata API. The OWD settings are included in the settings section of the metadata, specifically within the SharingSettings metadata type.

Steps to Export OWD:

1. Create a Package.xml File:

This file specifies the metadata components to retrieve. For OWD, you need to include the SharingSettings metadata type.



   

        *

        SharingSettings

   

    56.0

Retrieve Metadata:



Use a tool like Salesforce CLI (sfdx), ANT Migration Tool, or Workbench to retrieve the metadata defined in the package.xml.

Using Salesforce CLI:


Was this helpful?

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.