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

    SetObjectRights

    Scroll Prev Top Next More

    Revision history:

    Introduced in QPR 7.6.1 SP2

    Last changed in QPR 2012.2

     

    Sets object rights to an element for a user or a group.

     

    Synopsis:

     

    PGModel.SetObjectRights(ElementId, User, Parameters, Rights)

     

    Parameters:

     

    ElementID: Integer. ElementId must refer to a diagram element in the model. If Element ID = 0, it refers to the main diagram.

    User: String | ID. User name | User id | Group name | Group Id.

    Parameters: String. A semicolon-separated list of parameters. The supported parameter:

    ApplyToChildLevels: true | 1 | false | 0. If true, rights are set to the diagram defined by ElementId and all diagrams under that recursively. The default value is false.

    Rights: Integer; none (0), view (1), full (3). User rights cannot be set for administrator users or groups.

     

    Required Rights:

     

    Administrator or Model Administrator rights to the model.

     

    Return Values:

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

     

    RV_NOT_ENOUGH_RIGHTS

    RV_ELEMENT_IS_NOT_SUBPROCESS

    RV_INVALID_PARAMETER

    RV_USER_NOT_FOUND

    RV_CANNOT_SET_RIGHTS_FOR_ADMINISTRATORS

    RV_CANNOT_SET_RIGHTS_LOWER_OR_SAME_THAN_INHERITED_RIGHTS

    RV_SUCCESS

    RV_FUNCTION_CANNOT_BE_USED_IN_VALIDATION_SCRIPT

     

    Example Procedure:

     

    Sub SetObjectRightsForUser()

     Dim iResult

     iResult = PGModel.SetObjectRights(0, "USER/GROUP NAME", "ApplyToChildLevels=true", 1)

     If (iResult <> 0) Then

       MsgBox("Setting object rights failed: " & PGApplication.GetErrorMessage(iResult))

     Else

       MsgBox("Rights Applied")

     End If

    End Sub