Introduction

This 20-minute tutorial shows you how to create a Groovy script to work with Planning metadata, in this case, moving a member from one parent to another. The script includes RTPs to prompt users for input. You'll also learn how to create a right-click action menu with a menu item to call the script, and how to associate the action menu with a data form. Complete the sections in order.

Background

The EPM object model in Groovy gives you tools to design interactive ways for users to work with metadata, such as adding new members, renaming existing members, moving members under new parents, updating other metadata properties, and so on. Including run time prompts, or RTPs, in your Groovy scripts lets you prompt users for relevant values during these operations.

The EPM object model provides utility methods to perform the following tasks:

  • Retrieve the object representations for the various types of RTPs such as Member, Members, DateAsNumber, Member Range, and so on
  • Validate RTP values and veto the rule execution if the provided values are not valid

Prerequisites

Cloud EPM Hands-on Tutorials may require you to import a snapshot into a Cloud EPM Enterprise Service instance. A snapshot cannot be imported over an existing application or business process. Before importing the snapshot, use a separate Cloud EPM Enterprise Service instance or remove the existing application or business process from the instance you plan to use. Importing the snapshot does not automatically replace or restore existing content.

Before starting this tutorial, you must:

  • Have Service Administrator access to a Cloud EPM Enterprise Service instance.
  • Upload and import this snapshot into your instance. This snapshot requires the Planning business process. If you have already imported the snapshot for another Groovy tutorial, you can continue using that application without importing the snapshot again.

Note:

If you run into migration errors importing the snapshot, re-run the migration excluding the HSS-Shared Services component, as well as the Security and User Preferences artifacts in the Core component. For more information on uploading and importing snapshots, refer to the Administering Migration for Oracle Enterprise Performance Management Cloud documentation.

Tip:

The scripts you need for this tutorial are linked as text files within each section.

Loading Planning Calculation Variables

In this section, you upload calculation variables from an XML file for use in the Groovy script.

  1. Right-click the link for HP4_Plan2_Variables.xml, and save the file to your local drive.
  2. From the Home page, click Navigate (Navigate), then, under Create and Manage, click Rules to open Calculation Manager.
    Navigator showing Rules under Create and Manage
  3. On the System View tab, expand EPM Cloud, then HP4. Right-click Plan2 and select Import.
    System View with EPM Cloud and HP4 expanded and Import selected for Plan2
  4. Under File Import Details, browse to select HP4_Plan2_Variables.xml from your local drive.
  5. Under Location Details, make the following selections:
    • Application Type: EPM Cloud
    • Application: HP4
    • Cube: Plan2
    Import dialog with HP4_Plan2_Variables.xml selected and Location Details set to EPM Cloud, HP4, and Plan2
  6. Under Import Options, verify that Override Existing Objects is selected. This option is selected by default.
  7. Click Import. Review the import results (they may say Inserted or Updated), and then click OK.
    Import results showing calculation variables inserted
  8. Click Cancel to close the Import dialog box.

Creating a Groovy Script to Move Dimension Members

In this section, you implement a Groovy script to move an employee from one parent to another. We'll work with the predefined ManageEmployees form, which has been set up to capture employee information such as their Grade, Salary, Bonus, Phone, Email, Address, and Reporting Manager.

ManageEmployees form showing FY26
  1. In Calculation Manager, expand Plan2. Right-click Rules and select New.
    New command on the Plan2 Rules context menu
  2. For Name, enter Groovy Move Employee, then click OK.
    New Rule dialog with Groovy Move Employee entered for Name
  3. In the Rule Editor, change the Designer option to Edit Script and set the Script Type to Groovy Script.
    Rule Editor with Edit Script and Groovy Script selected
  4. Copy this script and paste it into the editor:
    1 /*RTPS: {Employee} {NewParent}*/
    2 def employee = rtps.Employee.member
    3 def newParent = rtps.NewParent.member
    4 employee.dimension.saveMember(["Member" : employee.name, "Parent" : newParent.name] as Map<String, Object>)
    

    1 Define all the run time prompts used by this rule on the first line.

    2 Get the Member object for the employee specified by the Employee run time prompt. The code rtps.Employee returns an RtpValue object for the Employee run time prompt, whereas rtps.Employee.member instructs the RtpValue object to return a Member object, which is what is required here.

    3 Get the Member object for the new parent specified by the NewParent run time prompt. The code rtps.NewParent returns an RtpValue object for the NewParent run time prompt, whereas rtps.NewParent.member instructs the RtpValue object to return a Member object, which is what is required here.

    4 Save the employee under the new parent. The code employee.dimension instructs the employee Member to return its Dimension object. So the full statement employee.dimension.saveMember() instructs the Dimension object to save the member with the specified property values, in this case the new parent.

    Note:

    This is a privileged method and will throw an exception if called by a user that does not have administrator privileges.
  5. On the toolbar, click Save (Save) to save the script. At the information message, click OK.
    Information message confirming Groovy Move Employee is saved
  6. Click Validate and Deploy (Validate and Deploy). For validation purposes, enter the following RTP values:
    • Employee: "Employee 3"
    • NewParent: "Part Time Employees"
    Enter RTP Values dialog with Employee 3 and Part Time Employees
  7. Click OK to validate and deploy the rule, then click OK to close the information message.

    Note:

    During this step, the rule is not executed; however, you must enter valid members for the validation process to succeed.
    Deploy information message confirming successful deployment
  8. Close Calculation Manager and return to the Planning browser window.

Creating Planning Action Menus to Run Groovy Scripts

In this section, you create an action menu called Manage Employees, with a right-click action menu item that runs the Groovy script.

  1. In Planning, click Navigator (Navigator), then, under Create and Manage, click Action Menus.

    Note:

    If you've completed other Groovy tutorials, the Manage Employees action menu may already exist. If it does, please proceed to step 4.
  2. Click Create Menu (Create Menu) to add an action menu.
    Create Menu dialog
  3. For Menu Name, enter Manage Employees, then click OK.
    Create Menu dialog with Manage Employees entered for Menu Name
  4. Select the Manage Employees action menu, then click Edit Menu (Edit Menu).
    Manage Employees action menu open for editing
  5. Click Add Child (Add Child). Enter or select the following values:
    Option FieldValue to Enter or Select
    Menu ItemMove Employee
    LabelMove Employee
    TypeBusiness Rule
    Required ParametersEmployee
    CubePlan2
    Business RuleGroovy Move Employee
    Add Child settings for the Move Employee business rule menu item
  6. Click Save. At the confirmation message, click OK.
    Information message confirming the menu item was saved
  7. Click Save to save the action menu. At the confirmation message, click OK.
    Information message confirming the menu was saved
    Saved Manage Employees action menu containing Move Employee

Associating Planning Action Menus with Forms

In this section, you associate the Manage Employees action menu with the ManageEmployees form.

  1. Click Navigator (Navigator), then select Data.
  2. Click ManageEmployees to open the form.
    ManageEmployees form showing FY26
  3. Click Actions, then select Edit to edit the form.

    A new dynamic tab is displayed with the form editor.

    Actions menu with Edit selected
  4. Select the Other Options tab.
    Other Options tab in the Edit ManageEmployees form editor

    Note:

    If you've completed other Groovy tutorials, the Manage Employees action menu may already be associated with the form. If it is, please close the Edit ManageEmployees tab and proceed to the next section, Testing the Groovy Script.
  5. Add Manage Employees to the Selected Menus list, then click Save.
    Manage Employees added to the Selected Menus list
  6. Click OK to close the information message.
    Information message confirming the form has been saved
  7. At the bottom of the page, close the Edit ManageEmployees dynamic tab to return to the data form.

Testing the Groovy Script

In this section, you run the rule from the ManageEmployees form to move employees.

To test the Groovy script, move Employee 3 to the Part Time Employees parent:

  1. Right-click Employee 3 and select Move Employee.
    Move Employee command on the Employee 3 context menu
  2. Verify that "Employee 3" is selected for the Select Employee prompt.
    Select Employee prompt with Employee 3 selected
  3. For the Employee New Parent prompt, enter "Part Time Employees".
    Employee New Parent prompt set to Part Time Employees
  4. Click Launch. At the information message, click OK.
    Information message confirming the Groovy Move Employee rule was successful

    Upon successful completion, Employee 3 is moved to the Part Time Employees parent.

    Employee 3 under Part Time Employees in the FY26 form
  5. Now, reverse the move: Right-click Employee 3, then select Move Employee.
  6. Verify that "Employee 3" is selected for the Select Employee prompt.
    Select Employee prompt with Employee 3 selected
  7. For the Employee New Parent prompt, enter "Full Time Employees".
    Employee New Parent prompt set to Full Time Employees
  8. Click Launch. At the information message, click OK.
    Information message confirming the Groovy Move Employee rule was successful

    Employee 3 is moved back to the Full Time Employees parent.

    Employee 3 restored to Full Time Employees in the FY26 form

    Note:

    After executing this rule, you need to perform a cube refresh so that aggregations properly reflect the new hierarchies.

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.