Customize Oneflow document name generation in Salesforce

Dineth Kurukularatchi
Dineth Kurukularatchi
  • Updated

When a Oneflow contract is created in Salesforce, the document name is generated automatically based on the record from which the contract is created. By default, the naming format is:

[Record Name] + [Template Name] + [Sequential Number]

This logic is defined by the Oneflow Contract Name Customization Flow. You can find this Flow in Setup > Process Automation > Flows > Oneflow Contract Name Customization.

Why Modify the Default Flow?

Modifying the default configuration of the Oneflow Contract Name Customization Flow allows you to:

  • Change the naming format for existing objects (Account, Contact, Opportunity, Lead)
  • Add naming logic for additional standard objects (e.g., Order, Quote)
  • Add naming logic for custom objects
  • Incorporate custom fields and logic into the document name

For example, in the default Flow configuration, the document name is generated as Record Name - Template Name #Counter. However, if you want to include additional fields like Close Date or Account Name, this can be achieved through Flow customization.

How the Naming Logic Works

The Flow receives the following inputs:

InputDescription
recordIdThe ID of the record from which the contract is being created
templateNameThe name of the selected Oneflow template
workspaceNameThe name of the selected Oneflow workspace
counterThe next sequential number
objectApiNameThe API name of the object (e.g., Opportunity, Account, MyCustomObject__c)

The Flow uses the objectApiName to determine which object the record belongs to and applies the appropriate naming logic. The result is returned as a text value in the generatedDocumentName output variable.

Important: If the Flow returns null or an empty value, or if the Flow fails to execute, the system automatically falls back to the default naming format (Record Name - Template Name #Counter). This ensures that contract creation is never blocked by Flow misconfiguration. For detailed debugging, you can review the debug logs and log entries in Salesforce.
Important: The counter variable is pre-incremented before being passed to the Flow. Use it directly in your formulas, do NOT add + 1.

Default Flow Configuration

The default Oneflow Contract Name Customization Flow includes logic for the following standard objects:

ObjectDefault Formula
Account{!Get_Account.Name} & " - " & {!templateName} & " #" & {!counter}
Contact{!Get_Contact.Name} & " - " & {!templateName} & " #" & {!counter}
Opportunity{!Get_Opportunity.Name} & " - " & {!templateName} & " #" & {!counter}
Lead{!Get_Lead.Name} & " - " & {!templateName} & " #" & {!counter}

Each branch:

  • Get Records – Fetches the record using the provided recordId
  • Formula Resource – Builds the document name using the record's fields, template name, and counter
  • Assignment – Sets the generatedDocumentName output variable

The Default outcome handles any object not explicitly configured, returning null – which triggers the system fallback to the default naming format.

Customize the Naming Format for Existing Objects

To change the naming format for Account, Contact, Opportunity, or Lead, edit the existing Formula Resources in the Flow.

Steps:

  1. Navigate to Setup > Process Automation > Flows
  2. Locate and open Oneflow Contract Name Customization
  3. Click Edit
  4. In the Resource Manager (left sidebar), expand Formula to see all Formula Resources

  5. Find the Formula Resource for the object you want to modify (e.g., Opportunity_Document_Name for Opportunity)
  6. Double-click the Formula Resource to edit it
  7. Modify the formula to match your naming convention

Example: Adding Close Date to Opportunity Name

Default Formula: {!Get_Opportunity.Name} & " - " & {!templateName} & " #" & {!counter}

Customized Formula: {!Get_Opportunity.Name} & " (" & TEXT({!Get_Opportunity.CloseDate}) & ") - " & {!templateName}

Result: My Opportunity (2025-12-31) - NDA #5

  1. Click Save
  2. Activate the Flow

Add Support for New Objects

To add support for a new object (e.g., Order or a custom object), you must add a new branch to the flow.

Steps:

  1. Open the Oneflow Contract Name Customization Flow in edit mode
  2. In the Decision element (Check Object Type), click Add Outcome
  3. Configure the new outcome:
    • Outcome Name: Order (or your object name)
    • Condition:
      • Field: {!objectApiName}
      • Operator: Equals
      • Value: Order (or your object API name)

  4. Connect the new outcome to a Get Records element:
    • Label: Get Order Record
    • Object: Order (or your object API name)
    • Filter: Order Id Equals {!recordId}

  5. Create a new Formula Resource:
    • Name: Order_Document_Name (or any preferred name)
    • Resource Type: Formula
    • Data Type: Text
    • Formula:
      • Let's say you want the document name to include the Order Number, Account Name, and Order Date in addition to the template name and counter.
      • {!Get_Order.OrderNumber} & " - " & {!Get_Order.Account.Name} & " - " & {!templateName} & " - " & TEXT({!Get_Order.EffectiveDate}) & " #" & {!counter}
      • Result: ORD-12345 - Acme Corp - NDA - 2025-12-31 #5

  6. Add an Assignment element to set the output:
    • Variable: generatedDocumentName
    • Operator: Set
    • Value: {!Order_Document_Name} (or Your formula resource name)

  7. Save and Activate the Flow

Note: You can add conditional logic to apply different naming formats based on field values.

Example: Different Name Format Based on Opportunity Stage

  1. From the Get Opportunity Record element, add a Decision element.
  2. Outcome 1: Is_Closed_Won – Condition: {!Get_Opportunity.StageName} Equals Closed Won
  3. Outcome 2: Default – Default outcome
  4. Add an Assignment for each outcome with different naming formulas.

Important Considerations

Maximum Length (80 Characters)

Document names cannot exceed 80 characters. The LWC component enforces this limit and will show a validation error if exceeded.

To prevent this, wrap your formula in the LEFT() function to automatically truncate the name:

LEFT(
  {!Get_Opportunity.Name} & " - " & {!templateName} & " #" & {!counter},
  80
)

This ensures the generated name is never longer than 80 characters.

Field-Level Security

When referencing fields in your formula, ensure the user has read access to those fields. If a user lacks access to a field used in the formula, the flow may fail or return an incomplete name.

Object Support

The default flow supports Account, Contact, Opportunity, and Lead. For any other object (standard or custom), you must add a new branch to the flow.

Flow Activation

After making changes to the flow, you must Save and Activate it. Inactive flows will not execute, and the naming will fall back to the default logic.

Use TEXT() to Convert Non-Text Fields

When working with date, number, currency or any other fields in your formula, you must use TEXT() to convert them to a text format:

TEXT({!Get_Opportunity.CloseDate})      // Converts Date to Text
TEXT({!Get_Opportunity.Amount})          // Converts Currency to Text
TEXT({!Get_Opportunity.Probability})     // Converts Percent to Text

Note: Without TEXT(), the formula will fail to save or execute properly.

Handling Null Values

Use BLANKVALUE() or IF() to handle null fields gracefully:

IF(
  {!Get_Opportunity.Account.Name} = NULL,
  {!Get_Opportunity.Name},
  {!Get_Opportunity.Account.Name} & " - " & {!Get_Opportunity.Name}
)

Troubleshooting

IssueSolution
Flow returns null or emptyThe system falls back to the default format. Check the Flow logic using the Flow debugger to identify errors. Review debug logs and log entries for detailed error information.
Flow not foundEnsure the Flow is activated.
New object not using Flow namingVerify the Decision branch exists and the objectApiName condition matches exactly (case-sensitive).
Name exceeds 80 charactersThe LWC will show a validation error. Use LEFT() in the Flow to truncate the name automatically.
Changes not taking effectEnsure you have activated the Flow after making changes.

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request