Using the publish API for Private Planning Versions

You can use the publish API (script function) to publish a private planning version.

Before you start

Before you use the publish API make sure you have checked the following:
  • You have created an application that contains a table and planning model for SAP Analytics Cloud.

  • You have assigned the planning model to the table.

  • You've made up your mind on how you want to visualize or expose the publish API to the application user (for example, you want the application user to use a button in order to publish a version).

  • If the user tries to publish a version that exceeds the resource limits and there are not enough resources available in the system for the publish operation, a correspondent message is displayed to the user.

When you publish a private version to an unrelated public version, the default publishing option is specified by the parameter updateChangedDataOnly. If the public target version is unrelated to the private version and updateChangedDataOnly is false, then the private version overwrites the public target version. If the public target version is unrelated to the private version and updateChangedDataOnly is true, then only the changed data is published to the public target version.
You can call this script function in two different ways:
  1. No input parameters are given (the original version is overwritten):

    In this case you can use the following scripting code:
    Sample Code
    // override the original version from which myActual was created
    
    var myActualVersion = Table_1.getPlanning().getPrivateVersion("myActual");
    
    if (myActualVersion) {
    
        myActualVersion.publish();
    
    };
    
  2. The target version is specified. In this case you can specify if you want to update the entire version or only those parts of the version that have been changed. You can use the following scripting code:
    Sample Code
    // override the forecast version with myActual and update only changed data
    
    var myActualVersion = Table_1.getPlanning().getPrivateVersion("myActual");
    
    var forecastVersion = Table_1.getPlanning().getPublicVersion("Forecast");
    
    if (myActualVersion && forecastVersion) {
    
        myActualVersion.publish(forecastVersion, true);
    
    };