AFC for Custom sObjects

Estimated reading: 2 minutes 19 views

Custom Salesforce objects require both admin configuration and developer enablement to use Auto Folder Creation (AFC). Admins define the AFC folder hierarchy and optional enhancements (categories, translations, related folders). Developers must create and deploy an Apex trigger that calls Cartularius AFC entry points for create/rename/delete operations.

When to use this

Use this page when:

  • You want to automate the AFC folder hierarchy for a custom object.
  • You are preparing a sandbox-to-production deployment plan that includes both config and code.
  • You need a single canonical checklist for developers + admins.

Prerequisites

  • Ability to modify Setup metadata (Global Value Set / Picklist Value Set).
  • Ability to deploy Apex triggers.
  • Admin ownership of AFC configuration rules.

How it works in Cartularius

Custom objects need two enablement layers:

Ensure AFC runs at record lifecycle events

Developers add an after insert / after update / after delete trigger that calls Cartularius AFC entrypoints:

  • GlobalDocumentManager.autoFolderCreation(Trigger.new)
  • GlobalDocumentManager.renameRecords(Trigger.new, Trigger.oldMap)
  • GlobalDocumentManager.sfRecordDeletion(Trigger.old)

Make the custom object available for AFC configuration

Admins (or release engineers) add the object API name (including __c) to the CDM SObjects Global Value Set so the object becomes selectable when configuring AFC.

Implementation / Configuration steps

Step 1: Deploy the custom object trigger

Use the following trigger pattern. Replace names in brackets with your object/trigger names.

trigger [CustomObjectTrigger] on [CustomObject__c] (after insert, after update, after delete) {

    if (Trigger.isInsert) {
        try {
            GlobalDocumentManager.autoFolderCreation(Trigger.new);
        } catch (Exception e) {
            for (SObject newRecord : Trigger.new) {
                newRecord.addError('Cartularius AFC folder creation failed: ' + e.getMessage());
            }
        }
    }

    if (Trigger.isUpdate) {
        try {
            GlobalDocumentManager.renameRecords(Trigger.new, Trigger.oldMap);
        } catch (Exception e) {
            for (SObject updatedRecord : Trigger.new) {
                updatedRecord.addError('Cartularius AFC folder rename failed: ' + e.getMessage());
            }
        }
    }

    if (Trigger.isDelete) {
        try {
            GlobalDocumentManager.sfRecordDeletion(Trigger.old);
        } catch (Exception e) {
            for (SObject oldRecord : Trigger.old) {
                oldRecord.addError('Cartularius AFC deletion maintenance failed: ' + e.getMessage());
            }
        }
    }
}

Step 2: Add a new entry to the CDM SObjects Global Value Set

  1. In Setup, open Picklist Value Sets.
  2. Open the CDM SObjects Global Value Set.
  3. Add the custom object API name(s), including __c.
  4. Save.

Step 3: Validate results

After deploying the trigger and completing the required admin configuration, validate end-to-end AFC behavior in the target environment.

CONTENTS
Discover the power of Cartularius in a personalized demo. Our experts will showcase live examples tailored to your business. Get your questions answered and see how our solution streamlines collaboration and accelerates processes. Schedule your demo today and unlock smarter document management.

Get the list

Please provide us with your Name, Job Title and Email Address and you will receive the complete predefined list of Document Categories and Document Types in your inbox.

Get Quote (Enterprises)

Please provide us with as much relevant detail on your needs as possible at this stage in the form below. We understand your business is unique and we would very much like to get you the best offer possible. Thank you!

Get Quote (Non-Profit)

Please provide us with as much relevant detail on your needs as possible at this stage in the form below. We understand your business is unique and we would very much like to get you the best offer possible. Thank you!