Use copy API on Versions
As an application designer or story developer, you can use the PlanningVersion.copy API for creating a private version from an existing version. This function only works for SAP Analytics Cloud models.
Before You Start
-
You've created an application or optimized story that contains a table and SAP Analytics Cloud planning model.
-
You've assigned the planning model to the table.
-
You've made up your mind on how to visualize or expose the copy API to the end users. For example, you may want them to click on a button to copy a version.
-
If a planning area is to be copied, make sure that a recommended planning area has been defined for the model.
-
If users try to copy a version that exceeds the resource limits and there aren't enough resources available in the system for the copying operation, they'll see a corresponding message.
-
Currently, the copy API only supports the options to copy all data, no data or planning area data.
-
All versions are copied with the default currency conversion, which can't be changed.
Example
var originalVersion = Table_1.getPlanning().getPrivateVersion("privateVersionToCopy"); if (originalVersion) { originalVersion.copy("targetVersionName", PlanningCopyOption.AllData, PlanningCategory.Budget) };
var originalVersion = Table_1.getPlanning().getPublicVersion("publicVersionToCopy"); if (originalVersion) { originalVersion.copy("targetVersionName", PlanningCopyOption.NoData) };
var originalVersion = Table_1.getPlanning().getPublicVersion("publicVersionToCopy"); if (originalVersion) { originalVersion.copy("Version"+ Date.now().toString(), PlanningCopyOption.PlanningArea)); }
var originalVersion = Table_1.getPlanning().getPrivateVersion("privateVersionToCopy"); if (originalVersion) { originalVersion.copy("Version"+ Date.now().toString(), PlanningCopyOption.PlanningArea, PlanningCategory.Forecast)); }