---
schema_version: "1"
id: d66d588fdb976cb79680cf576a4b6289a1b3e99727bc2ffb991688e1e9540d28
title: OrderOwnerSharingRule
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/object_reference/sforce_api_objects_orderownersharingrule.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_orderownersharingrule.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: ed0accc32cdf2e3ac5925a10d4ac4db006c41518572eaebdee48acecc45d3e49
description: Represents a rule which determines order sharing access for the order’s owners.
---
# OrderOwnerSharingRule

Represents a rule which determines order sharing access for the order’s owners.

![Note](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/images/icon_note.png)

#### Note

To enable access to this object for your org, contact Salesforce customer support. However, we recommend that you instead use Metadata API to programmatically update owner sharing rules because it triggers automatic sharing rule recalculation. The [SharingRules](https://developer.salesforce.com/docs/atlas.en-us.264.0.api_meta.meta/api_meta/meta_sharingrules.htm) Metadata API type is enabled for all orgs.

## Supported Calls

create(), delete(), describeSObjects(), getDeleted(), getUpdated(), query(), retrieve(), update(), upsert()

## Special Access Rules

Customer Portal users can't access this object.

## Fields

| Field | Details |
| --- | --- |
| CreatedById | 
Type

reference

Properties

Defaulted on create, Filter, Group, Sort

Description

ID of the creator of the order owner sharing rule.



 |
| CreatedDate | 

Type

dateTime

Properties

Defaulted on create, Filter, Sort

Description

Date when the order owner sharing rule was created.



 |
| Description | 

Type

string

Properties

Create, Filter, Nillable, Sort, Update

Description

Description of the order owner sharing rule. Maximum length is 1,000 characters.



 |
| DeveloperName | 

Type

string

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

Name of the developer of the order owner sharing rule.



 |
| GroupId | 

Type

reference

Properties

Create, Filter, Group, Sort

Description

ID of the group whose orders are shared.



 |
| Id | 

Type

ID

Properties

Defaulted on create, Filter, Group, idLookup, Sort

Description

ID of the order owner sharing rule.



 |
| LastModifiedById | 

Type

reference

Properties

Defaulted on create, Filter, Group, Sort

Description

ID of the user who last modified the order owner sharing rule.



 |
| LastModifiedDate | 

Type

dateTime

Properties

Defaulted on create, Filter, Sort

Description

Date when the order owner sharing rule was last modified.



 |
| Name | 

Type

string

Properties

Create, Filter, Group, idLookup, Namefield, Sort, Update

Description

Name of the order owner sharing rule. Maximum length is 80 characters.



 |
| OrderAccessLevel | 

Type

picklist

Properties

Create, Filter, Group, Restricted picklist, Sort, Update

Description

Access level for the order owner sharing rule.



 |
| SystemModstamp | 

Type

dateTime

Properties

Defaulted on create, Filter, Sort

Description

System modification time for the order owner sharing rule.



 |
| UserOrGroupId | 

Type

reference

Properties

Create, Filter, Group, Sort

Description

ID of the user or group with whom order access is shared.



 |

## Usage

Use this object to manage the sharing rules for orders. For example, the following code creates an order owner sharing rule between two public groups, which can also contain portal users.

OrderOwnerSharingRule rule = new OrderOwnerSharingRule();
rule.setName("RuleName"); // Set the sharing rule name
rule.setDeveloperName("RuleDeveloperName"); // Set the sharing rule developer name
rule.setGroupId("00Gx00000000000"); // Set the group of users to share records from 
rule.setUserOrGroupId("00Gx00000000001"); // Set the group of users to share records to
rule.setOrderAccessLevel("Edit");
connection.create(rule);

#### See Also

- [_Metadata API Developer Guide_: SharingRules](https://developer.salesforce.com/docs/atlas.en-us.264.0.api_meta.meta/api_meta/meta_sharingrules.htm "
    Metadata API Developer Guide: SharingRules - HTML (New Window)")