データモデル

Salesforceにおけるブランドコミュニティのデータモデルと、共有設定に関連するオブジェクト間の関係性を解説します。


データモデル全体像

主要なオブジェクト関係


User と Contact の関係

User オブジェクト

Community Userは、標準のUserオブジェクトとして存在します。

主要フィールド:

フィールドデータ型説明
ContactIdLookup(Contact)関連するContactレコード
AccountIdLookup(Account)Contactの所属Account(自動設定)
ProfileIdLookup(Profile)例: “R Design | Maker Community User”
UserTypePicklist”CustomerSuccess”, “PowerPartner” など

Contact オブジェクト

各Community Userに対応するContactレコード。

主要フィールド:

フィールドデータ型説明
AccountIdLookup(Account)所属する組織(Community Licensee Account)
EmailEmailログインメールアドレス

Account オブジェクト(Community Licensee)

Community Userが所属する組織を表すAccountレコード。

特徴:

  • Type = “Community Licensee”(または類似の値)
  • このAccountと同じIDを持つVendor BrandのレコードにSharing Set経由でアクセス可能

Vendor Brand (Maker_Code__c) の構造

🏢

Vendor Brandは、ブランド企業(メーカー)を表すカスタムオブジェクトです。各ブランドに対して1つのVendor Brandレコードが存在します。

3つのAccount参照フィールド

Vendor Brandオブジェクトには、3つの異なるAccount参照フィールドがあります。それぞれ異なる用途で使用されます。

フィールド名API名用途
Business AccountAccount__c実際のビジネス取引先株式会社◯◯(法人名)
Amocc AccountAmocc_Account__cシステム管理用システム管理会社のAccount
Owner AccountOwner_Account__c共有設定専用Community Licensee Account

Owner_Account__c の重要性

<!-- Maker_Code__c.Owner_Account__c フィールド定義 -->
<CustomField>
  <fullName>Owner_Account__c</fullName>
  <deleteConstraint>SetNull</deleteConstraint>
  <inlineHelpText>Sharing Set cannot be created, to share Design Family records, 
  based on the Owner.Account of Vendor Account record. Instead, we shall use 
  Owner_Account__c field.</inlineHelpText>
  <label>Owner Account</label>
  <referenceTo>Account</referenceTo>
  <relationshipName>Vendor_Brands</relationshipName>
  <type>Lookup</type>
</CustomField>

このフィールドが必要な理由:

Experience CloudのSharing Set Settingsでは、複数階層をまたいだ複雑なリレーションシップパスを使用した共有ルールを作成できません。

作成できない共有ルール:

User.Contact.Account = Design_Family.Maker_Code__r.Owner.Account

(Ownerを経由したAccount参照は不可)

作成可能な共有ルール:

User.Contact.Account = Design_Family.Maker_Code__r.Owner_Account__c

(直接ルックアップフィールド参照)


Design Family (Design_Family_Name__c)

基本構造

デザインファミリーは、ブランドが提供する製品デザインの集合体です。

主要フィールド:

フィールドデータ型説明
NameTextDesign Family Name (Eng)
Maker_Code__cLookup(Maker_Code__c)必須。関連するVendor Brand
Brand_Account_Id__cFormula(Text)Maker_Code__r.Account__c のID(共有判定用)
OwnerIdLookup(User)レコード所有者(Community User)

共有設定

<CustomObject>
  <sharingModel>Private</sharingModel>
  <externalSharingModel>Private</externalSharingModel>
</CustomObject>

Brand_Account_Id__c 数式フィールド

<CustomField>
  <fullName>Brand_Account_Id__c</fullName>
  <formula>CASESAFEID( Maker_Code__r.Account__c )</formula>
  <label>Brand Account Id</label>
  <type>Text</type>
</CustomField>

このフィールドは、Sharing Set Settingsでの共有判定に使用されます。


Product (Product__c)

基本構造

製品(Product Code)を表すオブジェクト。

主要フィールド:

フィールドデータ型説明
Product2_Brand__cLookup(Maker_Code__c)関連するVendor Brand
Owner_Account__cLookup(Account)共有設定用のAccount参照
OwnerIdLookup(User)レコード所有者

共有設定

<CustomObject>
  <sharingModel>Private</sharingModel>
  <externalSharingModel>Private</externalSharingModel>
</CustomObject>

その他の主要オブジェクト

My Catalog (My_Catalog__c)

共有モデル:

<sharingModel>ReadWrite</sharingModel>
<externalSharingModel>Private</externalSharingModel>

内部ユーザー間では ReadWrite だが、外部ユーザー間では Private

Room Design (Room_Design__c)

共有モデル:

<sharingModel>ReadWrite</sharingModel>
<externalSharingModel>Private</externalSharingModel>

PO (Purchase Order)

共有モデル:

<sharingModel>ReadWrite</sharingModel>
<externalSharingModel>Private</externalSharingModel>

ControlledByParent パターン

多くの子オブジェクトは、親オブジェクトの共有設定を継承します。

例: Design Version

<!-- Design_Version__c -->
<CustomObject>
  <sharingModel>ControlledByParent</sharingModel>
  <externalSharingModel>ControlledByParent</externalSharingModel>
</CustomObject>

親子関係:

Design_Family_Name__c (親)
  └─ Design_Version__c (子)
      ├─ Design_Mesh_Junction__c (孫)
      ├─ Design_Product_Attribute_Junction__c (孫)
      └─ Custom_Option_n_Design_Version_Junction__c (孫)
⚠️

重要: ControlledByParent を使用するオブジェクトでは、親オブジェクトの共有設定を変更すると、すべての子レコードの共有設定が自動的に連動して変更されます。


共有モデル統計

172個のカスタムオブジェクトの共有設定分布(主要なもの):

Sharing ModelExternal Sharing Modelオブジェクト数(例)
PrivatePrivate3 (Design_Family_Name__c, Product__c, Maker_Code__c)
ReadWritePrivate30+ (My_Catalog__c, PO__c, BOM_Material__c など)
ReadWriteReadWrite20+ (Action_Mirrored__c, Addresses__c など)
ControlledByParentControlledByParent80+ (Design_Version__c, PO_Line__c など)
📊

Private設定の意図

主要なビジネスオブジェクトで externalSharingModel = Private を採用しているのは、マルチテナント分離を実現するためです。これにより、各ブランドのデータが他のブランドから完全に隔離されます。


データフロー:レコード作成から共有まで

1. レコード作成時

// 擬似コード
const newDesignFamily = {
  Name: "Modern Chair Series",
  Maker_Code__c: vendorBrandId, // Vendor BrandのID
  OwnerId: currentUser.Id // Community User
};

2. 数式フィールドの自動計算

// Brand_Account_Id__c が自動計算される
Brand_Account_Id__c = Maker_Code__r.Account__c; // Owner Account

3. Sharing Set判定

// Sharing Set Settingのロジック(擬似コード)
if (currentUser.Contact.AccountId === designFamily.Brand_Account_Id__c) {
  // 同じブランドのユーザー → Read/Write権限を付与
  grantAccess(designFamily, currentUser, 'Edit');
} else {
  // 別のブランドのユーザー → アクセス不可
  denyAccess(designFamily, currentUser);
}

関連ドキュメント


更新履歴

  • 2026年1月21日: 初版作成