Skip to content

forcedotcom/sf-skills / plugins/builder/salesforce-development/skills/platform-data-manage

platform-data-manage

Verified

Salesforce data operations with 130-point scoring. Use to create, update, delete, bulk import/export, generate test data, and clean up org records via sf CLI and anonymous Apex. TRIGGER on creating test data, bulk import/export, sf data CLI commands, data-factory patterns for Apex tests, or seeding/cleaning org records. DO NOT TRIGGER for SOQL query writing only (use platform-soql-query), Apex test execution (use platform-apex-test-run), or metadata deployment (use platform-metadata-deploy).

FileKindSize
README.mdmarkdown4.5 KB
SKILL.mdskill md10.5 KB
assets/bulk/bulk-insert-10000.apexother12.3 KB
assets/bulk/bulk-insert-200.apexother12.4 KB
assets/bulk/bulk-insert-500.apexother13.1 KB
assets/bulk/bulk-upsert-external-id.apexother13.4 KB
assets/cleanup/delete-by-created-date.apexother15.9 KB
assets/cleanup/delete-by-name.apexother12.9 KB
assets/cleanup/delete-test-data.apexother16.6 KB
assets/cleanup/rollback-transaction.apexother12.4 KB
assets/csv/account-import.csvother1.8 KB
assets/csv/contact-import.csvother1.9 KB
assets/csv/custom-object-import.csvother1.1 KB
assets/csv/opportunity-import.csvother1.6 KB
assets/factories/account-factory.apexother5.6 KB
assets/factories/case-factory.apexother8.1 KB
assets/factories/contact-factory.apexother5.9 KB
assets/factories/custom-object-factory.apexother10.8 KB
assets/factories/event-factory.apexother9.6 KB
assets/factories/hierarchy-factory.apexother16.0 KB
assets/factories/lead-factory.apexother6.4 KB
assets/factories/opportunity-factory.apexother7.3 KB
assets/factories/task-factory.apexother8.1 KB
assets/factories/user-factory.apexother8.8 KB
assets/json/account-contact-tree.jsonconfig3.6 KB
assets/json/account-opportunity-tree.jsonconfig3.3 KB
assets/json/full-hierarchy-tree.jsonconfig5.8 KB
assets/soql/aggregate.soqlother12.3 KB
assets/soql/child-to-parent.soqlother9.8 KB
assets/soql/parent-to-child.soqlother8.6 KB
assets/soql/polymorphic.soqlother11.1 KB
assets/soql/subquery.soqlother16.2 KB
references/anonymous-apex-guide.mdmarkdown2.0 KB
references/bulk-operations-guide.mdmarkdown1.8 KB
references/bulk-testing-example.mdmarkdown4.9 KB
references/cleanup-rollback-example.mdmarkdown8.2 KB
references/cleanup-rollback-guide.mdmarkdown1.7 KB
references/crud-workflow-example.mdmarkdown4.0 KB
references/governor-limits-reference.mdmarkdown1.8 KB
references/orchestration.mdmarkdown7.0 KB
references/relationship-query-examples.mdmarkdown5.7 KB
references/sf-cli-data-commands.mdmarkdown2.8 KB
references/soql-relationship-guide.mdmarkdown2.0 KB
references/test-data-best-practices.mdmarkdown3.2 KB
references/test-data-factory-usage.mdmarkdown7.6 KB
references/test-data-patterns.mdmarkdown2.4 KB
scripts/soql_validator.pyscript10.9 KB
scripts/validate_data_operation.pyscript13.5 KB

assets/soql/child-to-parent.soql

View on GitHub
-- ═══════════════════════════════════════════════════════════════════════════════
-- CHILD-TO-PARENT QUERY (Dot Notation Pattern)
-- ═══════════════════════════════════════════════════════════════════════════════
--
-- Traverse UP the relationship hierarchy using dot notation.
-- Access parent fields directly from the child record query.
--
-- USE WHEN:
-- • Starting from child object and need parent details
-- • Filtering based on parent field values
-- • Need to flatten parent-child data into a single row
--
-- LIMITS:
-- • Maximum 5 levels of parent traversal
-- • Standard objects use relationship name (e.g., Account.Name)
-- • Custom objects use __r suffix (e.g., Custom_Parent__r.Name)
--
-- ═══════════════════════════════════════════════════════════════════════════════

-- ───────────────────────────────────────────────────────────────────────────────
-- BASIC: Contact with Account details
-- ───────────────────────────────────────────────────────────────────────────────
SELECT Id, FirstName, LastName, Email, Phone,
    Account.Id,
    Account.Name,
    Account.Industry,
    Account.Type
FROM Contact
WHERE Account.Industry = 'Technology'
ORDER BY Account.Name, LastName

-- ───────────────────────────────────────────────────────────────────────────────
-- TWO LEVELS: Contact with Account and Account Owner
-- ───────────────────────────────────────────────────────────────────────────────
SELECT Id, FirstName, LastName, Email,
    Account.Name,
    Account.Industry,
    Account.Owner.Name,
    Account.Owner.Email,
    Account.Owner.Department
FROM Contact
WHERE Account.Owner.IsActive = true
AND Account.Type = 'Customer'

-- ───────────────────────────────────────────────────────────────────────────────
-- THREE LEVELS: Opportunity Line Item to Product to Product Family
-- ───────────────────────────────────────────────────────────────────────────────
SELECT Id, Name, Quantity, UnitPrice, TotalPrice,
    Opportunity.Name,
    Opportunity.StageName,
    Opportunity.Account.Name,
    Product2.Name,
    Product2.ProductCode,
    Product2.Family
FROM OpportunityLineItem
WHERE Opportunity.StageName = 'Closed Won'
AND Opportunity.CloseDate = THIS_YEAR

-- ───────────────────────────────────────────────────────────────────────────────
-- CASE with Account and Contact chain
-- ───────────────────────────────────────────────────────────────────────────────
SELECT Id, CaseNumber, Subject, Status, Priority,
    Account.Name,
    Account.Industry,
    Account.BillingCity,
    Contact.Name,
    Contact.Email,
    Contact.Phone,
    Owner.Name
FROM Case
WHERE Status = 'New'
AND Account.Type = 'Customer'
ORDER BY Priority DESC, CreatedDate ASC

-- ───────────────────────────────────────────────────────────────────────────────
-- TASK with polymorphic Who and What (simple version)
-- ───────────────────────────────────────────────────────────────────────────────
SELECT Id, Subject, Status, ActivityDate,
    Who.Name,
    What.Name,
    Owner.Name
FROM Task
WHERE Status != 'Completed'
AND ActivityDate <= NEXT_WEEK
ORDER BY ActivityDate ASC

-- ───────────────────────────────────────────────────────────────────────────────
-- FILTERING on parent fields
-- ───────────────────────────────────────────────────────────────────────────────
SELECT Id, Name, StageName, Amount, CloseDate
FROM Opportunity
WHERE Account.Industry IN ('Technology', 'Healthcare', 'Finance')
AND Account.AnnualRevenue > 1000000
AND Account.BillingCountry = 'USA'
AND StageName NOT IN ('Closed Won', 'Closed Lost')

-- ───────────────────────────────────────────────────────────────────────────────
-- CUSTOM OBJECT: Child to Custom Parent
-- Replace field names with your actual API names
-- ───────────────────────────────────────────────────────────────────────────────
-- SELECT Id, Name, Amount__c, Date__c,
--     Parent_Object__r.Name,
--     Parent_Object__r.Status__c,
--     Parent_Object__r.Account__r.Name,
--     Parent_Object__r.Account__r.Owner.Name
-- FROM Child_Object__c
-- WHERE Parent_Object__r.Status__c = 'Active'
-- AND Parent_Object__r.Account__r.Industry = 'Technology'

-- ───────────────────────────────────────────────────────────────────────────────
-- SELF-REFERENTIAL: Account hierarchy (ParentId)
-- ───────────────────────────────────────────────────────────────────────────────
SELECT Id, Name, Industry, Type,
    Parent.Name AS ParentAccountName,
    Parent.Industry AS ParentIndustry,
    Parent.Parent.Name AS GrandparentAccountName
FROM Account
WHERE ParentId != null
ORDER BY Parent.Name, Name

-- ───────────────────────────────────────────────────────────────────────────────
-- USER hierarchy (ManagerId)
-- ───────────────────────────────────────────────────────────────────────────────
SELECT Id, Name, Username, Title, Department,
    Manager.Name AS ManagerName,
    Manager.Title AS ManagerTitle,
    Manager.Manager.Name AS SkipLevelManagerName
FROM User
WHERE IsActive = true
AND ManagerId != null
ORDER BY Manager.Name, Name

-- ═══════════════════════════════════════════════════════════════════════════════
-- APEX PROCESSING PATTERN
-- ═══════════════════════════════════════════════════════════════════════════════
/*
// Query with parent fields
List<Contact> contacts = [
    SELECT Id, FirstName, LastName,
        Account.Name,
        Account.Industry,
        Account.Owner.Name
    FROM Contact
    WHERE Account.Industry = 'Technology'
];

// Access parent fields directly
for (Contact con : contacts) {
    System.debug('Contact: ' + con.FirstName + ' ' + con.LastName);
    System.debug('  Account: ' + con.Account.Name);
    System.debug('  Industry: ' + con.Account.Industry);
    System.debug('  Owner: ' + con.Account.Owner.Name);
}
*/

-- ═══════════════════════════════════════════════════════════════════════════════
-- SF CLI USAGE
-- ═══════════════════════════════════════════════════════════════════════════════
-- sf data query \
--   --query "SELECT Id, Name, Account.Name, Account.Industry FROM Contact LIMIT 10" \
--   --target-org myorg \
--   --json
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall