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

    ExecuteProcedure

    Scroll Prev Top Next More

    Revision history:

    Introduced in QPR 2014.1

    Last changed in QPR 2023.1

     

    Performs a procedure in the model.

     

    Synopsis:

     

    PGModel.ExecuteProcedure(Procedure, Parameters, out Result)

     

    Parameters:

     

    Procedure: String. Defines the procedure to be executed. Currently supported procedures:

    ReplaceWith: replaces an element with another element.

    Parameters: String. A semicolon-separated list of parameters for the procedure.

    Supported parameters for the ReplaceWith procedure:

    oOriginalElement=<ElementId>[.<Instance>] | <ElementSymbol>[.<InstanceId>]: Defines the element and instance that will be replaced - a process step, store, organization item, or a custom element. If InstanceId has been defined, only that instance will be replaced. If InstanceId is not given, all instances of the element will be replaced. Diagram elements cannot be replaced.

    oReplacingElement=<ElementId> | <ElementSymbol>: Defines the element that is used to replace the original element. This element cannot be a diagram element.

    oMergeAttributes=True | False | 1 | 0: Defines if the custom attribute values of the original element are merged with the replacing element. If the element types do not match, this parameter is ignored.

    Merging the custom attribute values works differently depending on the type and cardinality of the attribute:

    Cardinality 1, simple types:

    oThe value is copied from the original element if the value is empty in the replacing element.

    Cardinality N, all attribute types:

    oAll values from the original element are added to the replacing element.

    oIf this is a relation attribute, duplicate values are not added.

    Cardinality 1 attribute sets:

    oEach value in the attribute set is processed separately, using these rules:

    When the attribute set has cardinality 1 text attribute, the value of the text attribute is copied from the original element if the value is empty in the replacing element.

    When the attribute set has cardinality N text attribute, all values of the text attribute from the original element are added to the replacing element.

    Cardinality 1 enumerated values:

    i.The value is copied from the original element if the value is empty in the replacing element.

    ii.If the enumerated values are the same and the value has sub-attributes, each sub-attribute value is processed separately, using these rules (just like for attribute sets).

    oDeleteOriginalElement=True | False | 1 | 0: Defines if the original element will be deleted after the replace has been done. The default value is False. If DeleteOriginalElement is True, the InstanceId cannot be given in the OriginalElementId parameter. If the element cannot exist without instances and all instances are replaced, the original element will be deleted regardless of the value of the DeleteOriginalElement parameter. If the element cannot be created on diagram, the original element will be deleted regardless of the value of the DeleteOriginalElement parameter.

    out Result: Variant. Either success or error. Not used with the "ReplaceWith" procedure.

     

    Required Rights:

     

    Modify rights to the all diagrams where the element instances are replaced, and at least view rights to the element that will be used as the replacement element. Full rights to the replacing element are needed to merge custom attribute values between the original element and the replacing element.

     

    Return Values:

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

     

    RV_SUCCESS

    RV_INVALID_PARAMETER

    RV_APPLICATION_QUIT_CALLED

    RV_ACCESS_DENIED

    RV_MODEL_NOT_OPEN

    RV_FUNCTION_CANNOT_BE_USED_IN_VALIDATION_SCRIPT

    RV_ELEMENT_NOT_FOUND

    RV_INSTANCE_NOT_FOUND

    RV_CANNOT_REPLACE_ELEMENT

    RV_CANNOT_REPLACE_ELEMENT_WITH_DIFFERENT_TYPE

    RV_CANNOT_REPLACE_SUBPROCESS

    RV_CANNOT_REPLACE_WITH_SUBPROCESS

    RV_CANNOT_DELETE_BASE_MODEL_ELEMENT

     

    Example Procedure:

     

    iResult = PGModel.ExecuteProcedure("replacewith", "ORIGINALELEMENT=CHILD1;REPLACINGELEMENT=BASE1;DELETEORIGINALELEMENT=true", oResult)