In Oracle Cloud EPM, Groovy scripting has become a powerful tool for automating business processes, ensuring real-time validations, and enhancing interactivity. This blog explores a practical use case where a Groovy business rule dynamically sets substitution variables and validates Data Maps before executing Smart Push operations.
The rule also demonstrates on using runtime prompts (RTPs) to set values for Substitution Variables, validate Data Map existence, execute Smart Pushes for specific members, and log user execution details.
The objective of the Groovy script is as follows:
- Dynamically retrieve runtime prompt (RTP) values provided by the user.
- Update substitution variables with the RTP values for Snapshot Version, Years, and Source Version.
- Validate the existence of specific Data Maps in the application before executing them.
- Use Smart Push to transfer data for a specific members.
- Log execution details, including confirmation messages and the user who executed the rule.
Script Initialization: Capturing Runtime Prompts
At the top of the script, the Runtime Prompts (RTPs) are captured and converted to strings for use in the script.
rtps
: Thertps
object holds the values passed into the rule during execution.toString()
: Ensures that RTP values are treated as strings, even if numeric.
This section makes the script dynamic and user-driven.
Setting Substitution Variables
The script updates substitution variables (Version
, Years
, Version
) dynamically in the application. Substitution variables allow for flexible data calculations and reporting based on these values.
setSubstitutionVariableValue()
: This method updates the value of substitution variables in the application dynamically.
hasDataMap()
: Checks whether the specified Data Map exists in the application.getDataMap()
: Retrieves the Data Map object for execution.createSmartPush()
: Creates a Smart Push object that will transfer data.execute()
: Executes the Smart Push operation.- The parameters are:
"Years"
: Uses theYears
RTP value."Version"
: Uses the Version RTP value.
- The execute flag indicates the Smart Push will run synchronously (wait for completion before continuing).
If the Data Map exists, the Smart Push is executed, and a confirmation message is logged. If not, the script logs an error message.
Executing a Second Data Map
The same approach is repeated for another Data Map 2
- Dynamic Execution: Users can pass values via RTPs, making the script highly adaptable.
- Error Handling: Validating Data Maps before execution prevents runtime failures.
- Efficiency: Using Smart Push ensures that only relevant data for specific periods is pushed, reducing processing time.
- Auditability: Logging user details and execution messages enhances transparency and traceability.
Happy Grooving!!!!
No comments:
Post a Comment