データモデル
Salesforceにおけるブランドコミュニティのデータモデルと、共有設定に関連するオブジェクト間の関係性を解説します。
データモデル全体像
主要なオブジェクト関係
User と Contact の関係
User オブジェクト
Community Userは、標準のUserオブジェクトとして存在します。
主要フィールド:
| フィールド | データ型 | 説明 |
|---|---|---|
ContactId | Lookup(Contact) | 関連するContactレコード |
AccountId | Lookup(Account) | Contactの所属Account(自動設定) |
ProfileId | Lookup(Profile) | 例: “R Design | Maker Community User” |
UserType | Picklist | ”CustomerSuccess”, “PowerPartner” など |
Contact オブジェクト
各Community Userに対応するContactレコード。
主要フィールド:
| フィールド | データ型 | 説明 |
|---|---|---|
AccountId | Lookup(Account) | 所属する組織(Community Licensee Account) |
Email | ログインメールアドレス |
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 Account | Account__c | 実際のビジネス取引先 | 株式会社◯◯(法人名) |
| Amocc Account | Amocc_Account__c | システム管理用 | システム管理会社のAccount |
| Owner Account | Owner_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)
基本構造
デザインファミリーは、ブランドが提供する製品デザインの集合体です。
主要フィールド:
| フィールド | データ型 | 説明 |
|---|---|---|
Name | Text | Design Family Name (Eng) |
Maker_Code__c | Lookup(Maker_Code__c) | 必須。関連するVendor Brand |
Brand_Account_Id__c | Formula(Text) | Maker_Code__r.Account__c のID(共有判定用) |
OwnerId | Lookup(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__c | Lookup(Maker_Code__c) | 関連するVendor Brand |
Owner_Account__c | Lookup(Account) | 共有設定用のAccount参照 |
OwnerId | Lookup(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 Model | External Sharing Model | オブジェクト数(例) |
|---|---|---|
| Private | Private | 3 (Design_Family_Name__c, Product__c, Maker_Code__c) |
| ReadWrite | Private | 30+ (My_Catalog__c, PO__c, BOM_Material__c など) |
| ReadWrite | ReadWrite | 20+ (Action_Mirrored__c, Addresses__c など) |
| ControlledByParent | ControlledByParent | 80+ (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 Account3. 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日: 初版作成