Analyze Lightning Record Page field assignments for any Salesforce object
From opspal-salesforcenpx claudepluginhub revpalsfdc/opspal-commercial --plugin opspal-salesforce--object {Object} --org {org-alias}Analyzes Lightning Record Pages for any Salesforce object across any org, generating comprehensive field inventories and executive summaries with optimization recommendations.
sf org display --target-org {org})/workspace/instances/salesforce/{org}//sfpageaudit --object {Object} --org {org-alias}
/sfpageaudit --object {Object} --org {org-alias} --output-dir /custom/path
--object (REQUIRED): Salesforce object API name
Opportunity, Account, Contact, Lead, Custom__c--org (REQUIRED): Salesforce CLI org alias
sf org list--output-dir (OPTIONAL): Custom output directory path
/workspace/instances/salesforce/{org}/Per Lightning Page CSV ({PageName}_fields.csv):
Field_API_Name,Field_Label,Field_Type,Field_Classification,Help_Text,UI_Behavior
AccountId,Account ID,reference,Standard,,required
Amount,Amount,currency,Standard,,required
Custom_Field__c,Custom Field,text,Custom,This is help text,none
Executive Summary ({Object}_Lightning_Pages_Executive_Summary.md):
/sfpageaudit --object Contact --org my-production
Expected Output:
🔍 Analyzing Lightning Pages for Contact in org: my-production
✓ Validated Salesforce connection
✓ Found 3 Lightning Pages for Contact
✓ Retrieved FlexiPage metadata
✓ Extracted 487 total field references
✓ Retrieved Contact metadata (245 fields)
✓ Enriched all field inventories
✓ Generated executive summary
📁 Artifacts saved to: /workspace/instances/salesforce/my-production/
- Contact_Sales_Page_fields.csv (142 fields)
- Contact_Support_Page_fields.csv (98 fields)
- Contact_Default_Page_fields.csv (167 fields)
- Contact_Lightning_Pages_Executive_Summary.md
📊 Analysis Summary:
- 3 Lightning Pages analyzed
- Field counts: 98-167 fields per page
- 2 recommendations for optimization
💡 Next steps:
- Review executive summary for optimization opportunities
- Share CSVs with training team for documentation
- Validate field visibility aligns with security requirements
/sfpageaudit --object CustomProduct__c --org my-sandbox
Expected Output:
🔍 Analyzing Lightning Pages for CustomProduct__c in org: my-sandbox
✓ Validated Salesforce connection
✓ Found 1 Lightning Page for CustomProduct__c
✓ Retrieved FlexiPage metadata
✓ Extracted 84 field references
✓ Retrieved CustomProduct__c metadata (112 fields)
✓ Enriched field inventory
✓ Generated executive summary
📁 Artifacts saved to: /workspace/instances/salesforce/my-sandbox/
- CustomProduct_Record_Page_fields.csv (84 fields)
- CustomProduct__c_Lightning_Pages_Executive_Summary.md
/sfpageaudit --object Lead --org my-scratch-org
Expected Output:
🔍 Analyzing Lightning Pages for Lead in org: my-scratch-org
✓ Validated Salesforce connection
⚠️ No Lightning Pages found for Lead
This means one of the following:
1. The object uses Salesforce default page layouts (not Lightning Pages)
2. No custom Lightning Pages have been deployed for this object
3. FlexiPage metadata may not be accessible (check permissions)
💡 Troubleshooting:
- Verify Lightning Pages exist in Setup → Lightning App Builder
- Check if object uses Classic page layouts instead
- Confirm Metadata API permissions are enabled
Each CSV contains the following columns:
| Column | Description | Example |
|---|---|---|
Field_API_Name | Salesforce API name | AccountId, Custom_Field__c |
Field_Label | Human-readable label | Account ID, Custom Field |
Field_Type | Data type | reference, text, picklist, currency |
Field_Classification | Standard or Custom | Standard, Custom |
Help_Text | Field-level help text | Enter customer notes (or empty) |
UI_Behavior | Page behavior | required, readonly, none |
Goal: Identify overly complex pages that may need simplification
Process:
/sfpageaudit for target objectGoal: Document which fields each user profile can see
Process:
/sfpageaudit for objectGoal: Prioritize which fields to migrate based on actual usage
Process:
/sfpageaudit for objects being migratedGoal: Create accurate field reference guides for end users
Process:
/sfpageaudit for objectSymptoms:
❌ Error: Not authenticated to org 'my-org'
Solution:
# Authenticate to org
sf org login web --alias my-org
# Verify authentication
sf org display --target-org my-org
Symptoms:
❌ Error: INVALID_TYPE: FlexiPage
Solution:
--use-tooling-api flag for queriesSymptoms:
❌ Error: sObject type '{Object}' is not supported
Solution:
__c suffix is includedSymptoms:
❌ Error: Permission denied: /workspace/instances/...
Solution:
/tmp firstAnalyze multiple objects in sequence:
# Analyze core CRM objects
for obj in Account Contact Opportunity Lead; do
/sfpageaudit --object $obj --org my-production
done
Compare page complexity across orgs:
# Run for each org
/sfpageaudit --object Opportunity --org production
/sfpageaudit --object Opportunity --org uat
/sfpageaudit --object Opportunity --org dev-sandbox
# Compare field counts from summaries
Save to project-specific directory:
/sfpageaudit --object Account --org my-org \
--output-dir /projects/crm-audit/lightning-pages/
/tmp before copying to final destination/dedup - Analyze duplicate detection rules/audit-automation - Review automation framework/deploy-report-template - Deploy analytics templates/reflect - Submit session feedback for improvementsWhen executing this command, follow the 9-Step Lightning Page Analysis Playbook:
/workspace/instances/salesforce/{org}/mkdir -p {instance_dir}export INSTANCE_DIR={instance_dir}sf org display --target-org {org} --json
sf data query \
--query "SELECT Id, DeveloperName, MasterLabel FROM FlexiPage WHERE Type = 'RecordPage' AND EntityDefinitionId = '{Object}'" \
--target-org {org} \
--use-tooling-api \
--json > /tmp/flexipages_list.json
# Create package.xml
# Retrieve all FlexiPages for object
sf project retrieve start \
--manifest /tmp/package.xml \
--target-dir /tmp/flexipage-metadata \
--target-org {org}
python3 {plugin_root}/scripts/lib/extract-flexipage-fields.py \
/tmp/flexipage-metadata/force-app/main/default/flexipages/{PageName}.flexipage-meta.xml \
/tmp/{PageName}_fields.csv
sf sobject describe \
--sobject {Object} \
--target-org {org} \
--json > /tmp/{Object}_metadata.json
python3 {plugin_root}/scripts/lib/enrich-field-metadata.py \
/tmp/{PageName}_fields.csv \
/tmp/{Object}_metadata.json \
/tmp/{PageName}_enriched.csv
python3 {plugin_root}/scripts/lib/generate-lightning-page-report.py \
--org {org} \
--object {Object} \
--input-dir /tmp \
--output-file /tmp/{Object}_Lightning_Pages_Executive_Summary.md
# Copy all CSVs
cp /tmp/*_enriched.csv {instance_dir}/
# Copy executive summary
cp /tmp/{Object}_Lightning_Pages_Executive_Summary.md {instance_dir}/
# Report success
echo "✓ All artifacts saved to {instance_dir}/"
/tmp files after completion or failureReport progress to user after each step:
🔍 Analyzing Lightning Pages for {Object} in org: {org}
✓ Validated Salesforce connection
✓ Found {N} Lightning Pages for {Object}
✓ Retrieved FlexiPage metadata
...