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.
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 your Cloud EPM Enterprise Service instance. Before you can import a tutorial snapshot, you must request another Cloud EPM Enterprise Service instance or remove your current application and business process. The tutorial snapshot will not import over your existing application or business process, nor will it automatically replace or restore the application or business process you are currently working with.
Before starting this tutorial, you must:
- Have Service Administrator access to a Cloud EPM Enterprise Service instance.
- Upload and import this snapshot into your Planning instance.
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.
- Right-click the link for HP4_Plan2_Variables.xml, and save the file to your local drive.
- From the Home page, navigate to Rules (under Create and Manage) to open Calculation Manager. In the System View, expand EPM Cloud > HP4. Right-click Plan2 and select Import.
- Under File Import Details, browse to select HP4_Plan2_Variables.xml from your local drive.
- Under Location Details, make the following selections:
- Application Type: EPM Cloud
- Application: HP4
- Cube: Plan2
- Under Import Options, select Override Existing Objects.
- Click Import. Review the import results (they may say Inserted or Update), and then click OK.
- 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.

- In Calculation Manager, create a rule named Groovy Move Employee for the Plan2 cube.
- In the Rule Editor, change the Designer option to Edit Script and set the Script Type to Groovy Script.
- Copy this script and paste it into the editor:
- On the toolbar, click Save (
) to save the script.
- Click Validate and Deploy (
). Enter RTP values for validation purposes, then click OK:
- Employee:
"Employee 3"
- NewParent:
"Employee 1"
- Click OK when prompted, then close Calculation Manager.


/*RTPS: {Employee} {NewParent}*/def employee = rtps.Employee.member
def newParent = rtps.NewParent.member
employee.dimension.saveMember(["Member" : employee.name, "Parent" : newParent.name] as Map‹String, Object›)
![]()
Define all the run time prompts used by this rule on the first line.
Get the Member object for the employee specified by the
Employee
run time prompt.
The code rtps.Employee
returns a 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.
Get the Member object for the new parent specified by the
NewParent
run time prompt.
The code rtps.NewParent
returns a 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.
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.Note:
During this step, the rule is not executed; however, you must enter valid members for the validation process to succeed.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.
- From the Home page, navigate to Action Menus (located under Create and Manage) and create an action menu named Manage Employees.
- Edit the Manage Employees action menu and add a child menu item named Move Employee. Enter or select the following options to define the menu item:
Option Field Value to Enter or Select Menu Item Move Employee Label Move Employee Type Business Rule Required Parameters Employee Cube Plan2 Business Rule Groovy Move Employee - Click Save, then click OK to save the menu item. Finally, click Save again to save the action menu.



Associating Planning Action Menus with Forms and Testing Groovy Scripts
In this step, you associate the action menu with the ManageEmployees form and test your script.
- Navigate to Forms (located under Create and Manage) and edit the ManageEmployees form.
- On the Other Options tab, add the Manage Employees context menu to the Selected Menus list.
- Click Finish to save changes to the form.
- Close the Form Manager and return to the Home page.
- Click Data to display the list of data entry forms, then click ManageEmployees to open the Manage Employees form.
- To test the Groovy script, move Employee 3 to be a child of Employee 1:
- Right-click Employee 3 to display the context menu, and select Move Employee.
- Verify that
"Employee 3"
is selected for the Select Employee prompt. - For the Employee New Parent prompt, enter
"Part Time Employees"
. - Click Launch.
- Now, reverse the move:
- Right-click Employee 3, and select Move Employee.
- Verify that
"Employee 3"
is selected for the Select Employee prompt. - For the Employee New Parent prompt, enter
"Full Time Employees"
. - Click Launch.
Employee 3 is moved back to the Full Time Employees parent.
Note:
After executing this rule, you need to perform a cube refresh so that aggregations properly reflect the new hierarchies.



Upon successful completion, Employee 3 is moved to the Part Time Employees parent.
Next Tutorial
Related Links
Moving Dimension Members with Groovy
F87328-01
October, 2023
Copyright © 2023, Oracle and/or its affiliates.