afv-library/skills/salesforce-experience-lwr-site/docs/configure-guest-sharing-rules.md
Scott Mo 690f722a0b
@W-21482430 feat: migrate exp lwr site knowledge docs to skill (#27)
* feat: migrate exp lwr site knowledge docs to skill

* feat: small wording adjustment

* feat: stricter wording for loading reference docs

* feat: incorporate new guest user fix

* feat: rename docs to use verb and update some wording

* feat: updating wording

* feat: wording adjustments

* fix: resolve pr comments

* fix: rm old references

* fix: rm extra comma

* fix: make LLM always load the reference docs

* fix: wording

* feat: incorporate core changes and wording updates

* fix: guest user name

* fix: stricter wording

* fix: revert to repeat instructions

* fix: rm "manual" to avoid confusion

* fix: updating mcp tools calls instructions

* feat: handle component slots

* fix: add MCP hints for objectList

---------

Co-authored-by: Jeff Carey <jeffrey.carey@salesforce.com>
Co-authored-by: Hemant Singh Bisht <hsinghbisht@salesforce.com>
2026-03-18 20:41:27 +05:30

43 lines
1.7 KiB
Markdown

# Guest User Sharing Rules (Public Sites Only)
**Use when** the user explicitly wants to make the site **public** (accessible to unauthenticated visitors). If the site is private/login-required, guest sharing rules are not needed.
If sharingRules metadata is not available locally in force-app/main/default/sharingRules, retrieve it from the org before creating new rules.
## Retrieve Full SharingRules Schema
Use the metadata MCP tool with metadataType "SharingRules" to retrieve schema.
## XML Example
```xml
<?xml version="1.0" encoding="UTF-8"?>
<SharingRules xmlns="http://soap.sforce.com/2006/04/metadata">
<sharingGuestRules>
<fullName>ShareAccountsWithSiteGuest</fullName>
<accessLevel>Read</accessLevel>
<includeHVUOwnedRecords>false</includeHVUOwnedRecords>
<label>Share Accounts With Site Guest</label>
<sharedTo>
<guestUser>[site Guest User's CommunityNickanme]</guestUser>
</sharedTo>
<criteriaItems>
<field>Name</field>
<operation>notEqual</operation>
<value>null</value>
</criteriaItems>
</sharingGuestRules>
</SharingRules>
```
## Critical Requirements
1. **SharedTo Element**: Must use `<guestUser>{site Guest User's CommunityNickanme}</guestUser>` (not URL path prefix).
2. **includeHVUOwnedRecords**: Required field. Set to `false` unless records owned by high-volume site users should be included.
3. **One XML file per object**: Put all rules for a given object in one file. Do not create additional.
## Common Mistakes
- Using `<role>` or `<group>` instead of `<guestUser>` in sharedTo
- Omitting the required `includeHVUOwnedRecords` field
- Using `includeRecordsOwnedByAll` (that's for `sharingCriteriaRules`, not guest rules)