QPR Knowledge Base 2017.1

SaveModelEx

SaveModelEx

Previous topic Next topic No directory for this topic  

SaveModelEx

Previous topic Next topic Topic directory requires JavaScript Mail us feedback on this topic!  

Revision history:

Introduced in QPR 8.1

Last changed in QPR 2012.2

 

Saves the current model to the server or to a file. In addition to regular saving, this command can be used to save the model as a new version, save the model to a branch, or replace a model.

 

Synopsis:

 

PGModel.SaveModelEx(Operation, Parameters)

 

Parameters:

 

Operation: String. Defines the save operation that is used. Supported operations:

Save. Saves the current model to the server or to a file in the regular way. In the case the model has version management enabled, the behavior is as follows:

o"Save changes to current version" option is set for the model: Changes are saved to the current version.

o"Save as new model version" option is set for the model: The model is saved as a new version and the version info dialog is displayed. In the case user interface is hidden, the operation fails.

o"Prompt" option is set for the model. A dialog asking whether the model should be saved as a new version is displayed. In the case user interface is hidden, the operation fails.

SaveAs. Saves the model as a new server or file model. This can be used also to save a server model as a file model and vice versa. In the case the server model name already exists, this operation can be used to save the model as a new version. Supported parameters: ServerModelName, FileName, FileReplace, Password, NewVersion + optional version info parameters

Replace. Replaces an existing server model with the current model. Functionality is otherwise similar to the ReplaceModel command. The following parameters can be used: ServerModelName, CopyUserRights + optional version info parameters.

NewVersion. Saves the current model as a new version. Parameters can be used to define version information and branch.

Parameters: String. A semicolon-separated list of parameters for the selected operation. Supported parameters:

ServerModelName: String. Server path + model name.

NewVersion: true | false. If this is true and a server model already exists, the model is saved as a new version.

FileName: String. Path and name of a file model.

FileReplace: true | false. Defines if a similarly named file model should be replaced.

Password: String. File model password.

CopyUserRights: true | false. Defines whether user rights are copied from latest model version in the target model or branch to current model. (Save as new version / Replace)

Model.Branch: String.

Model.Version: String.

KeepOldVersionPublished: true | false. Defines whether the old version remains published in QPR Portal when the model is saved as a new version.

LockOldVersion: true | false. Defines whether the old version is locked when the model is saved as a new version.

Status: Integer (enum). Sets the model's version information Status as enumeration index value (integer). Default model enumerations: Draft = 0, Current State = 1, Proposal = 2, Approved = 3, Implemented = 4

Author: String. Defines the model author (no connection to actual users)

Comment: String. Comment for the model.

 

Required Rights:

 

View rights to PGModel.

 

Return Values:

Below are listed the return values that this function can return:

 

RV_APPLICATION_QUIT_CALLED
RV_MODEL_NOT_OPEN
RV_INVALID_PARAMETER
RV_NOT_CONNECTED_TO_SERVER
RV_MODEL_DOES_NOT_USE_VERSION_MANAGEMENT
RV_CANNOT_SAVE_AS_NEW_VERSION_MODEL_MUST_BE_SAVED_FIRST
RV_CANNOT_SAVE_CHECKED_OUT_MODEL_AS_NEW_VERSION
RV_NOT_ENOUGH_RIGHTS (only admins can set status & author in Save As/NewVersion operations)
RV_FILE_ALREADY_EXISTS
RV_ONLY_ADMINISTRATOR_CAN_SAVE_SERVER_MODEL_AS_FILE_MODEL
RV_MODEL_DOES_NOT_EXIST
RV_INVALID_MODEL_PATH
RV_CANCELLED
RV_BRANCH_DOES_NOT_EXIST
RV_ACCESS_DENIED
RV_FAILED_LOADING_EMBEDDED_DOCUMENTS_FROM_SERVER
RV_ERROR_DURING_SAVE
RV_CANNOT_SAVE_MODEL
RV_UNKNOWN_ERROR

RV_FUNCTION_CANNOT_BE_USED_IN_VALIDATION_SCRIPT
 

 

Example Procedure:

 

Sub SaveActiveModel

 Dim iResult

 iResult = PGModel.SaveModelEx("NewVersion", "Model.Branch=Development")

 If (iResult <> 0) Then

   MsgBox "Saving the model failed: " + PGApplication.GetErrorMessage(iResult)

 End If

End Sub