Please enable JavaScript to view this site.

QPR Knowledge Base 2023.1

  •      
  • Navigation: Developer's Guide > QPR Web Services Foundation > Functions

    AddReference

    Scroll Prev Top Next More

    Revision history:

    Introduced in QPR 8.1

    Last changed in QPR 2016.1

     

    Add references to objects (defined in targetObjectIds) into referenceAttribute of objects defined by objectIds. Reference attributes define relations between objects and e.g. Portal actions have parents and external parents as reference attributes.

     

    Synopsis:

     

    void AddReference(string sessionId, string objectIds, string referenceAttribute, string targetObjectIds, string options)

     

    Return Value:

     

    None.

     

    Parameters:

     

    sessionId: String. ID of an authenticated session.

    objectIds: String. A comma-separated list of FullID's of objects to be modified (i.e. which gain references to target objects). When adding users to groups, this must contain the users to be added to the groups. When adding groups for users, this must contain the groups to be added.

    referenceAttribute: String. Name of the reference attribute. When adding users to groups, use the 'groups' typename attribute. When adding groups to users, use the 'users' typename attribute.

    targetObjectIds: String. A comma-separated list of FullID's of object to which references should be created. When adding users to groups, this must contain the groups to which users are added. When adding groups for users, this must contain the users to which groups are added.

    options: String. A comma-separated list of options.

     

    Example Procedure:

     

    ServiceClient client = new ServiceClient("WSHttpBinding_IService");

    string sessionId = client.Authenticate("qpr", "demo");
    string[][] attributes = { new string[] { "Description", "Hello from QPR Web Services Foundation" }, new string[] { "Category", "Initiative" } };

    string objectId = client.CreateObject(sessionId, "PO", "actionplan", "Action Plan created via WS API", "", attributes, "");

    string[][] attributesForCopy = { new string[] { "Description", "Copied object" }, new string[] { "Category", "Initiative"} };

    string copiedObjectId = client.CreateCopy(sessionId, objectId, "", attributesForCopy, "");

    // set the first object as the parent for the copied object

    client.AddReference(sessionId, copiedObjectId, "parentobjects", objectId, "");

    client.LogOff(sessionId);

    client.Close();