After completing this lesson, you will be able to:
After completing this lesson, you will be able to:
Create a data action popup with scripting
Scenario: Create a Data Action Popup with Scripting
Watch this video to learn more about the team's requirement for a data action that is extended with scripting to include custom popups.
Business Scenario
Your team has started working with the extended planning story and have been copying versions and year using the extended data action button you created. They have added a number of new data actions due to the different version and year combinations required in the planning stories.
You suggest further enhancing the data action button with a popup, where instead of simply running the data action, planners will be prompted to select the required source and target version and year.
After working with your colleague Kevin to fully understand the business requirement for the extended data action, you'll create a data action popup that:
Prompts the planner to select the source and target year when they select the Copy Data data action button.
Provides them with a custom dialog when the data action is running and copying and refreshing the data in the table.
Refreshes and sorts new members alphanumerically each time the page is opened, ensuring the planners have the most up to date options to select.
Code Used in the Scenario
In the following examples, you can see the code used in the scenario and exercise to extend the planning story.
Select Data Popup
The following script is used so that when the OK button is selected:
The wait popup dialog is triggered.
The data selection popup prompts planners to specify the values for the four parameters using the dropdowns.
The Copy Data data action begins running, copying and refreshing the data in the table.
The wait popup saying The process is running. Please wait... appears then closes when the data action has finished running.
The Copy Data button script is updated so that instead of the data action running with specific source and target parameters, a popup dialog will appear allowing the planners to select source and target versions and years they require.
The following script is added to SO_Planning - updateDropdowns to ensure that new dimension members are available in the dropdowns when the page is opened:
Code snippet
// clean up the dropdowns before adding values to them
DD_PublishAs_Versions.removeAllItems();
DD_Delete_Version.removeAllItems();
// retrieve all private versions available in the model
var privVersions = TBL_Planning.getPlanning().getPrivateVersions();
//if private version exists
if (privVersions.length > 0) {
// iterate over the private versions
for (var i=0; i<privVersions.length; i++ ) {
// add them to the dropdown boxes
DD_PublishAs_Versions.addItem(privVersions[i].getId(),privVersions[i].getDisplayId());
DD_Delete_Version.addItem(privVersions[i].getId(),privVersions[i].getDisplayId());
if (selectedPrivateVersion === "" && i === 0) {
DD_PublishAs_Versions.setSelectedKey(privVersions[i].getId());
DD_Delete_Version.setSelectedKey(privVersions[i].getId());
}
}
BTN_PublishAs.setVisible(true);
BTN_Delete.setVisible(true);
BTN_Copy_Data.setVisible(true);
DD_Delete_Version.addItem("ALL","All versions");
DD_Delete_Version.setSelectedKey("ALL");
} else {
BTN_Delete.setVisible(false);
BTN_PublishAs.setVisible(false);
BTN_Copy_Data.setVisible(false);
}