Conga Product Documentation

Welcome to the new doc site. Some of your old bookmarks will no longer work. Please use the search bar to find your desired topic.

Use Case: Automated Billing Date Calculation using Workflow

Business Context

Organizations that manage agreements with recurring billing must ensure that upcoming billing dates are calculated accurately and consistently. Manual updates to billing dates are error-prone and time-consuming, especially when factors such as Billing Frequency, Calendar Cycle Start, Contract End Date, and Today's Date influence the outcome. Automating this calculation improves data integrity, reduces operational overhead, and ensures compliance with contract terms by preventing billing beyond the agreement's end date.

Overview

This use case demonstrates how to automate the calculation and update of Next Billing Date and Next Billing End Date on an Agreement record using Workflows. The workflow leverages custom fields, variables, formulas, and activities (Assignment, If Else, Update Record) to validate inputs, compute cycle boundaries, respect manual overrides, and enforce contract limits. The automation triggers only when relevant billing-related fields change and the agreement is not activated.

Scenario

A billing administrator at a subscription-based company needs to automate billing cycle management for agreements. The administrator configures a workflow that:

  • Initializes fiscal and frequency parameters (e.g., Calendar Cycle Start mapped to month; Billing Frequency mapped to interval).
  • Validates or defaults the Next Billing Date to Today when missing or outdated.
  • Calculates the Next Billing End Date by adding the appropriate number of months and subtracting one day to mark the cycle boundary.
  • Checks if a Billing Preference Override is enabled; if true, it sets Next Billing Date to the Contract End Date and stops automatic calculations.
  • Ensures the calculated Next Billing End Date does not exceed the Contract End Date; if it does, billing stops at contract completion; otherwise, both Next Billing Date and Next Billing End Date are updated for the next cycle.

Prerequisite

The following custom fields exist on the Agreement object:
  • Billing Preference Override Indicator (Boolean)
  • Next Billing Date (Date)
  • Next Billing End Date (Date)
  • Billing Frequency (Picklist — values: Monthly, Quarterly, Half-Yearly, Yearly)

For more details about how to create a field, see Creating a New Field.
  1. Create the Workflow. To learn more about workflow creation, see Creating Workflows topic. Enter the following sample data:
    FieldDescription
    Details
    NameSet_Next_Billing_Date_on_Agreement
    Display NameSet Next Billing Date on Agreement
    Workflow Type
    Workflow TypeStandalone Workflow
    TriggerRecord Trigger
    Object NameAgreement
    Trigger Info
    Display NameSet Next Billing Date on Agreement
    Reference NameSet_Next_Billing_Date_on_Agreement
    Action TypeUpdate
    When to run the workflow for updated recordsOnly when the record is updated to meet the trigger condition.
    Trigger Condition for UpdateStarts the workflow only when billing-related fields are modified and the Agreement is not yet active.

    First condition

    • Field: Status
    • Operator: Not Equal To
    • Value: Activated

    Second condition

    • Field: Next Billing Date
    • Operator: IsChanged
    • Value: False

    Third condition

    • Field: Next Billing End Date
    • Operator: IsChanged
    • Value: False
    The workflow is created in Draft status with one Record Trigger activity. It executes only when relevant billing fields change and the Agreement is not yet activated. This ensures recalculation happens only when needed and avoids unnecessary runs for active Agreements.
  2. Create the following workflow variables to store intermediate values used during calculations:
    To learn more about variable creation, see Defining Variables within a Workflow.
    Variable NameData TypeSample ValueDescription
    FiscalYearStartMonthInteger0Start month of the fiscal year.
    FiscalPeriodNumberInteger1Billing frequency in months (1 = Monthly, 3 = Quarterly, etc.).
    Effective_NextBillingDateDate12/31/2030Stores the validated Next Billing Date.
    MonthsToBeAddedInteger0Number of months to add to reach the next billing cycle.
    NextBillingEndDateDate12/31/2030Stores the computed Next Billing End Date.
  3. Define the following formulas to calculate the billing start and end dates based on Agreement data.
    To learn more about formula creation, see Defining Formulas within a Workflow.
    PurposeNameData TypeFormula Expression
    Converts the Calendar Cycle Start (e.g., "January") into a numeric month (1–12).Get_CalendarCycleStart_MonthIntegerFN.CASE(FN.TEXT({{Agreement.BillingPreference.CalendarCycleStart}}),"January",1,"February",2,"March",3,"April",4,"May",5,"June",6,"July",7,"August",8,"September",9,"October",10,"November",11,"December",12,0)
    Maps billing frequencies (Monthly, Quarterly, Half-Yearly, Yearly) to numeric month intervals.Get_BillingFrequency_NumberIntegerFN.CASE(FN.TEXT(Agreement.BillingFrequency_c),"Quarterly",3,"Monthly",1,"Half-Yearly",6,"Yearly",12,1)
    Determines the next billing start date. If the current date is empty or outdated, defaults to today's date.Get_NextBillingDateDateFN.IF(Agreement.Next_Billing_Date_c == null,FN.TODAY(),FN.DATETIMEVALUE(Agreement.Next_Billing_Date_c) > FN.TODAY() ? Agreement.Next_Billing_Date_c : FN.TODAY())
    Calculates how many months should be added to move from the current billing date to the next billing cycle.FR_MonthsToBeAddedIntegerFN.IF(FN.MONTH(FN.DATETIMEVALUE($Variables.Effective_NextBillingDate)) >= $Variables.FiscalYearStartMonth,(FN.FLOOR((FN.MONTH(FN.DATETIMEVALUE($Variables.Effective_NextBillingDate)) - $Variables.FiscalYearStartMonth) / $Variables.FiscalPeriodNumber) + 1) * $Variables.FiscalPeriodNumber,(FN.FLOOR((12 + FN.MONTH(FN.DATETIMEVALUE($Variables.Effective_NextBillingDate)) - $Variables.FiscalYearStartMonth) / $Variables.FiscalPeriodNumber) + 1) * $Variables.FiscalPeriodNumber)
    Calculates the next billing end date based on billing frequency and contract duration.FR_nextBillingEndDateDateFN.IF(Agreement.BillingFrequency_c.Equals("One Time"),Agreement.ContractEndDate,FN.ADDDAYS(FN.ADDMONTHS($Variables.Effective_NextBillingDate, $Variables.MonthsToBeAdded),-1))
  4. Add Workflow Activities:
    This step defines the workflow activities that automate billing date calculations and updates in sequence.
    1. Configure Billing Cycle Parameters: Add one Assignment activity to set all required workflow variables in a single step. This activity initializes fiscal values, validates the billing start date, calculates the months to add, and computes the next billing end date. For more details, see Assignment Activity topic.
      FieldValue
      Select Variable TypeWorkflow Variable
      PurposeWorkflow Variable Key Value mapping:
      Configure Billing Cycle Parameters: initializes fiscal values, validates the billing start date, calculates the months to add, and computes the next billing end date.FiscalYearStartMonthGet_CalendarCycleStart_Month
      FiscalPeriodNumberGet_BillingFrequency_Numb
      Set Effective Next Billing Date: validate the billing start date or default to today's date.Effective_NextBillingDateGet_NextBillingDate
      Calculate Months to Be Added: compute how many months need to be added to move from the current billing date to the next billing cycle.
      Note: This calculation considers the billing frequency (for example, 1 for monthly or 3 for quarterly cycles).
      MonthsToBeAddedFR_MonthsToBeAdded
      Compute Next Billing End Date: calculate the Next Billing End Date using the effective billing date and computed months. The computed date defines the billing period boundary for each agreement record.NextBillingEndDateFR_NextBillingEndDate
    2. Check Billing Preference Override: Add an If Else activity to check whether the agreement has a manual billing preference override. If the override is active, automatic calculations are skipped. Enter the following sample data in the activity. Enter the following sample data in the activity. For more details, see If Else Activity topic.
      Properties
      FieldOperatorValue
      Billing Preference Override IndicatorEqualstrue
      Next Billing DateNot Equal To12/31/2030

      If True: Stop automatic billing calculation and set Next Billing Date equal to the Contract End Date.

      If False: Continue automatic calculation and update billing dates normally.

    3. Update Next Billing Date: Add Update Record activities for both paths. Set the "Select Type to find records to Update and Set Their Values" field to "Update content object" and enter the following data for both the Update record activities respectively. For more details, see Update Record topic.
      ConditionFields to Update
      If Else Activity OutputFieldValueDescription
      If True (Manual Billing Preference = True)Next_Billing_Date_cContractEndDate (Variable)The workflow stops automatic billing date calculation. It sets the Next Billing Date to match the Contract End Date, ensuring billing does not continue beyond the contract's validity.
      If False (Manual Billing Preference = False)Next_Billing_End_Date_cNextBillingEndDate (Variable)The workflow continues with automatic billing. It updates the Next Billing End Date using the value calculated earlier in the workflow (NextBillingEndDate variable).
    4. Compare Next Billing End Date with Contract End Date: Add an If Else activity to the Done output of the Update Records activity (added to the False output in the previous step) to ensure calculated billing end date does not exceed the contract end date. Enter the following sample data in the activity. For more details, see If Else Activity topic.
      Properties
      FieldOperatorValue
      Contract End Date (Object Field)Greater ThanNextBillingEndDate (Variable)

      This condition compares two dates:

      • Contract End Date: The official end date of the agreement.

      • NextBillingEndDate: The calculated billing cycle end date.

      If the contract end date is greater than the calculated billing end date, billing can continue normally. Otherwise, billing must stop at the contract's end.

    5. If True (ContractEndDate > NextBillingEndDate): Add the Update Records activity to allow billing to continue within the contract period when the Contract End Date is later than the calculated Next Billing End Date. In this case, the workflow updates both the Next Billing Date and Next Billing End Date fields on the agreement using the calculated variable values. Enter the following sample data in the activity. For more details, see Update Record topic.
      FieldValue
      Select Type to find records to Update and Set Their ValuesUpdate Context object
      Fields to update mapping:
      Next_Billing_Date_cNextBillingDate (Variable)
      Next_Billing_End_Date_cNextBillingEndDate (Variable)
    6. If False (ContractEndDate ≤ NextBillingEndDate): Stop billing when the calculated Next Billing End Date has reached or passed the Contract End Date. In this case, the workflow ensures that billing does not extend beyond the contract's end. Link the False output of this step to the Update Record configuration used in Step Update Next Billing Date (True branch) to finalize billing and stop future billing cycles.

By separating the True and False paths:

  • The True branch continues billing within valid contract limits and updates both billing fields.

  • The False branch stops billing at the contract's end, preventing further cycles beyond the agreement's duration.