How do I configure business rules for defaulting flow instance names?

Use the Oracle Visual Builder Studio (VB Studio) functionality within your application to setup business rules on the Redwood Flow Submission page.

Set up a business rule that automatically defaults the flow instance name when you submit a flow.
Note:

You can perform this task only if you have the right privileges to access VB Studio.

Here are some examples of code you can use to configure the business rules based on the flow parameters.

Example 1: Flow Instance Name based on flow parameters

/* eslint-disable dot-notation */
define([], () => {
  'use strict';
  /**
   * Default value expression for PayrollFlowInstances.InstanceName 
   * @param {object} context
   * @return {string}
   */
  function getPayrollFlowInstancesInstanceName(context) {
    const { $objectContext, $fields, $modules, $user } = context;
// PAYROLL and PAYROLL_PERIOD are Base Parameters Names which can be retrived 
    // from My Client Groups > Payroll Flow Patterns for a flow pattern
    let payroll = $fields.parameters.PAYROLL.$value();
    let period = $fields.parameters.PAYROLL_PERIOD.$value();
    return payroll + "|" + period;
  }
  return { getPayrollFlowInstancesInstanceName };
});

Example 2: Flow Instance Name based on username and time stamp of flow submission

/* eslint-disable dot-notation */
define(['oj-hcm/common/js/date-utils'], (HcmDateUtils) => {
  'use strict';
  /**
   * Default value expression for PayrollFlowInstances.InstanceName 
   * @param {object} context
   * @return {string}
   */
  function getPayrollFlowInstancesInstanceName(context) {
    const { $objectContext, $fields, $modules, $user } = context;
       // This function gets current Date and Time as per user preference.
    function getCurrentTimeStamp() {
      return HcmDateUtils.DateUtils.getUserPreferredDateString(new Date().toISOString(), true);
    }
    let currentDateTime = getCurrentTimeStamp();
    // this line below appends username and current date time with underscore.
    return $user.userName + "_" + currentDateTime;
  }

  return { getPayrollFlowInstancesInstanceName };
});