Please enable JavaScript to view this site.

QPR Knowledge Base 2023.1

  •      
  • Navigation: Developer's Guide > QPR API > The Object Model > QPR Modeling > PGModel Commands

    ReplaceModel

    Scroll Prev Top Next More

    Revision history:

    Introduced in QPR 7.3.1

    Last changed in QPR 2012.2

     

    Replaces a server model given as parameter with the model that is currently open. Options allow selecting whether existing user rights are overwritten.

     

    Synopsis:

     

    PGModel.ReplaceModel(ServerPathName | ModelID, Options)

     

    Parameters:

     

    ServerPathName: String. Name and path of the model that is going to be replaced.

    OR

    ModelID: Integer. ID of the model that is going to be replaced.

    Options: String. A ";" separated list of additional parameters. The following options are supported:

    ReplaceUserRights: Defines whether existing user rights are replaced by those in the new model. TRUE or FALSE.

     

    Required Rights:

     

    Administrator.

     

    Return Values:

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

     

    RV_SUCCESS

    RV_APPLICATION_QUIT_CALLED

    RV_MODEL_NOT_OPEN

    RV_UNKNOWN_ERROR

    RV_CANNOT_SAVE_MODEL

    RV_INVALID_MODEL_PATH

    RV_INVALID_PARAMETER

    RV_ONLY_ADMINISTRATORS_CAN_OVERWRITE_SERVER_MODELS

    RV_MODEL_IS_RESERVED

    RV_FAILED_LOADING_EMBEDDED_DOCUMENTS_FROM_SERVER

    RV_ONLY_ADMINISTRATORS_CAN_REPLACE_SERVER_MODELS

    RV_FUNCTION_CANNOT_BE_USED_IN_VALIDATION_SCRIPT

     

    Example Procedure:

     

    Sub ReplaceModelWithNew

     iResult = oModel.ReplaceModel("\\NewModel", "ReplaceUserRights=TRUE")

     If (iResult <> 0) Then

       MsgBox "Replacing a server model failed: " + PGApplication.GetErrorMessage(iResult)

     End If

    End Sub