Using the publish API for Public Planning Versions

You can use the publish API (script function) to publish public planning versions.

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).

Example

The following script shows how you can use the publish API to replace the Version Management option in the Tools section of the view time toolbar at runtime:
Sample Code
// publish modified public version "Actual" => Toolbar Button Publish Data / VersionManagement

var actualVersion = Table_1.getPlanning().getPublicVersion("Actual");

if (actualVersion) {

    if(actualVersion.isDirty()) {

        actualVersion.publish();

    };

};

Example

The following script shows how you can use the publish API to replace the dialog Publish All in the Publish Data button of the view time toolbar at runtime:
Sample Code
// publish all modified public versions => Toolbar Button Publish Data

var publicVersions = Table_1.getPlanning().getPublicVersions();

for (var j = 0; j < publicVersions.length; j++) {

    if (publicVersions[j].isDirty()){

        publicVersions[j].publish();

    };

};