Skip to content

Conversation

@devin-ai-integration
Copy link

@devin-ai-integration devin-ai-integration bot commented Sep 25, 2025

What does this PR do?

Adds Salesforce automation that creates an "IT Request" Case when a Contact's Needs_Support__c checkbox field changes from false to true. The implementation includes:

  • Custom checkbox field Needs_Support__c on Contact object
  • Apex trigger that fires only when the flag changes from false to true (prevents duplicate Case creation)
  • Auto-created Cases have Subject "Support Needed for {Contact.Name}" and "IT Request" record type (if available)
  • Permission Set to grant field-level access to the custom field
  • Comprehensive test coverage with bulk update scenarios

Acceptance Criteria

  • ✅ Trigger only fires when Needs_Support__c changes to true (not on other Contact updates)
  • ✅ Creates Case with correct Subject format and links to Contact
  • ✅ Assigns "IT Request" record type if available in the org
  • ✅ Prevents duplicate Case creation on repeated Contact edits
  • ✅ Handles bulk Contact updates correctly
  • ✅ 100% test coverage with passing unit tests

Testing Notes

Automated Testing:

  • ContactSupportTriggerTest.createsCaseWhenFlagFlipsTrue(): Verifies single Case creation and duplicate prevention
  • ContactSupportTriggerTest.bulkUpdateCreatesCasesOnceEach(): Validates bulk processing (5 Contacts → 5 Cases)

Manual CLI Verification:

  • Deployed to alex@cognition.sandbox org successfully
  • Seeded Contact and flipped flag to true → Created exactly 1 Case with correct Subject and Contact linkage
  • Subsequent Contact update (without flag change) → No additional Cases created

Important Notes:

  • RecordType "IT Request" is queried dynamically; if not found, Cases are created without specific record type
  • Permission Set Contact_Needs_Support grants field access but needs assignment to appropriate users in production orgs

Checklist

  • This change has been approved by the CLI Review Board or approval isn't required
  • Does this follow the deprecation policy?

What issues does this PR fix or reference?

Implements Contact-triggered Case creation automation as requested in Devin session: https://app.devin.ai/sessions/d96eedaca0804048a71aa1af98ccc6c7

Requested by: Alex Peng (@alexpeng-cognition)

Review Focus Areas

  • RecordType handling: Verify "IT Request" exists in target orgs or confirm graceful fallback is acceptable
  • Permission assignment: Ensure Contact_Needs_Support permission set deployment strategy for production
  • Trigger logic: Confirm duplicate prevention works correctly with the falsetrue condition
  • Subject template: Validate "Support Needed for {Contact.Name}" matches exact requirements

devin-ai-integration bot and others added 6 commits September 25, 2025 01:31
… becomes true

Co-Authored-By: Alex Peng <alex.peng@cognition.ai>
…ips to true; includes tests

Co-Authored-By: Alex Peng <alex.peng@cognition.ai>
…ationship from test

Co-Authored-By: Alex Peng <alex.peng@cognition.ai>
Co-Authored-By: Alex Peng <alex.peng@cognition.ai>
…ggerTest

Co-Authored-By: Alex Peng <alex.peng@cognition.ai>
Co-Authored-By: Alex Peng <alex.peng@cognition.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant