Use Object Functions for Scheduled Processes

Scheduled processes are batch jobs that capture data and allow objects to act on that data.

Use the Scheduled Processes tool to run jobs to manipulate a set of records for a specific business need, or to get printable output with information about certain records. Schedule business logic code and update a set of records periodically, on a daily, weekly, or monthly basis, asynchronously, by just specifying the object's name and its function.

Note: To schedule object functions, your role must include the ZCX_MANAGE_EXTENSIBLE_OBJECT_PRIV privilege.

You can use scheduled processes in several scenarios. Here are a few examples of when you may need to schedule processes:

  • To perform mass update of records based on certain criteria.

  • To trigger workflows based on criteria that will be met in the future, as a workaround for time-based workflows.

  • To run custom logic with heavy updates that can be scheduled during off-hours.

The following procedure describes how to create a scheduled process for a Groovy object function.

Before you begin scheduling the object function, it's recommended that you perform the following steps:

  • Record the API name of the object as the object name.

  • Record the object function name.

  • Ensure that the object function compiles and runs properly using validation or trigger invocation mechanism within Application Composer, where runtime message debugging is supported.

  • Test capacity runs to determine the best batch size to handle large data sets. See Best Practice for Scheduling Object Functions: Test Capacity Runs.

The above steps are best practices to ensure that there's no impact on existing operations or the data in your production environment.

To create a scheduled process for a Groovy object function:

  1. Click Navigator, and then select Scheduled Processes.

  2. In the Scheduled Processes work area, click Schedule New Process.

  3. Leaving the type as Job, in the Name drop-down list, search and select Schedule Custom Groovy Object Functions, and then click OK.

  4. On the Process Details page, do the following:

    1. In the Object Name field, enter the object's API name. For example, OpportunityVO.

      Note: The object name you provide here must be the same as the object's API name on Application Composer's Object Overview page. Also, if you have any jobs scheduled from a previous release you must change the object name to match the object's API name on Application Composer's Object Overview page.
    2. In the Object Function field, enter the object function name. For example, OpptyMsg.

    3. Do one of the following:

      • Click the Advanced button to define the schedule, document output, and notifications.

      • Submit with the default schedule.

    See the Submitting Scheduled Processes and Process Sets section in the Oracle Applications Cloud Using Common Features guide for detailed information.

A few things to note:

  • You can write a function as complex as needed.

  • You can write a function to return values in a .txt file.

    The .txt file displays any values that the Groovy code returns. To view the .txt file of a process, click the status link for that process.

  • Each scheduled process has a runtime limit of 30 minutes to run an object function. This is to prevent long-running jobs that can consume large amounts of resources to support object functions operating on large volumes of data.

    Note: The 30 minute limit only applies to validation and execution of the object function operations specified for that run. As long as the required database transaction handling has begun within the allocated 30 minutes, the completion of the scheduled process can span past the 30 minute limit. This enables database inserts and updates of large data sets that often take a long time to complete their operation. Hence, the end-to-end processing time can be longer than 30 minutes.

    If your Groovy script triggers a long-running process that's implemented via ESS/PLSQL, any Groovy triggers already created on the target object won't get called. This is because ESS/PLSQL operates directly at the database level, bypassing ADF and the model layer.

  • Each job run constitutes a transaction. This means that all the operations specified by the Groovy script in the object function have to run to completion to complete the transaction. Otherwise, the transaction is rolled back and no records are updated.

  • Once the job execution starts, the Cancel button won't work and you can't cancel the job.

  • If a record is updated, the Last Updated By value changes to the user who submitted the job, and the Last Updated Date value changes to the date and time of the update.

  • The log file displays any errors occurred during the process. To view the log file of a process, click the status link for that process.

For more information about scheduled processes and how to use them, refer to your product's implementation guide.

Troubleshoot Scheduled Processes for Groovy Object Functions

Processing a lot of object rows in a scheduled Groovy object function at the same time may require some debugging.

Here's how you can troubleshoot such scheduled processes. To help with troubleshooting:

  1. Define an object function to return a string (or stringBuilder constituting the string). Populate information like the number of rows processed and failed, or the exceptions that were thrown. This value will be printed on the job output, which can be used for debugging.

  2. Add the println function in object functions and enable runtime messages to help determine the exact cause for failure.

    See Runtime Messages for more information about the println function.

  3. However, the runtime messages of scheduled Groovy object functions don't display the println messages. So, as a workaround, you can create a custom button for the object function with the println function, and then invoke that button from the object's detail page.

    See Actions and Links for information on creating buttons.

To view the log file and job output:

  1. Click Navigator > Tools > Scheduled Processes.

  2. Find your scheduled process and select it.

    You can refresh the search results to see the latest status.

  3. In the Log and Output section, click the attachment link to download the console log file.
    Note: If the object function was defined to have no return values, only the console log file is displayed and is downloaded when you click the link. Otherwise, an Attachment dialog opens with the console log file and the console text file.
  4. Review the log and job output.