Possible Error Messages in the Context of Version Management APIs
Learn how to prevent possible error messages when you use version management APIs.
Operate on Deleted Planning Versions
A previously deleted versions (no matter if it was deleted by the script APi or through user interaction in the application), will behave different from a non-deleted version.
Return values for calls made on deleted versions
PlanningVersion.getId() => returns last ID before deletion PlanningVersion.isDirty() => returns last modified stated before deletion PlanningVersion.deleteVersion() => returns true (the promised state was reached) PlanningVersion.publish() => returns false (the promised state cannot be reached) PlanningVersion.publishAs() => returns false (the promised state cannot be reached) PlanningVersion.revert() => returns true (the promised state was reached)
Reproduction
// delete new Budget version and operate on it afterwards var newBudgetVersion = Table_1.getPlanning().getPublicVersion("newBudget"); if (newBudgetVersion) { console.log("VersionId before deletion:" + newBudgetVersion.getId()); newBudgetVersion.deleteVersion(); console.log("VersionId after deletion:" + newBudgetVersion.getId()); newBudgetVersion.publish(); };
When calling any action function (revert, publishAs, publish or delete), the following error message will be displayed: Version 'newBudget' does not exist anymore.
Publish a Private Version with a Wrong Name
There are several errors that can occur when you use the publishAs API.
Empty string as version name
Below code will lead to an error, as the version name may not be empty:
// below code will lead to an error, as the version name may not be empty var myActualVersion = Table_1.getPlanning().getPrivateVersion("myActual"); if (myActualVersion) { myActualVersion.publishAs(""); };
The following error message is shown: Enter a name for your version before you publish it.
Too long string as version name
Below code will lead to an error, as the version name is too long:
// below code will lead to an error, as the version name is too long var myActualVersion = Table_1.getPlanning().getPrivateVersion("myActual"); if (myActualVersion) { myActualVersion.publishAs("255characters"); };
The following error message is displayed: Enter a version name that is shorter than 255 characters.
Unauthorized characters in version name
Below code will lead to an error, as the version name contains characters that are not allowed:
// below code will lead to an error, as the version name contains characters that are not allowed var myActualVersion = Table_1.getPlanning().getPrivateVersion("myActual"); if (myActualVersion) { myActualVersion.publishAs("\:Version"); };
The following error message is displayed: Enter a version name that doesn't contain the characters \\ : ; ' = [ ].
Name already exists
Below code will lead to an error, as the version name already exists:
// below code will lead to an error, as the version name already exists var myActualVersion = Table_1.getPlanning().getPrivateVersion("myActual"); if (myActualVersion) { myActualVersion.publishAs("Actual"); };
The following error message is displayed: You can't save this version with name 'Actual', because this name already exists. Please use a different name.
Delete actual version
Below code will lead to an error, as the actual version may not be deleted.
// below code will lead to an error, as the actual version may not be deleted var actualVersion = Table_1.getPlanning().getPublicVersion("Actual"); if (actualVersion) { actualVersion.deleteVersion(); };
The following error message is displayed: You can't delete the public version of category 'Actual'. This version always has to be available.