Please enable JavaScript to view this site.

QPR Knowledge Base 2019.1

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

CreateObject

Scroll Prev Top Next More

Revision history:

Introduced in QPR 8.1

Last changed in QPR 2016.1

 

Create QPR object of defined type so that name, parent object(s) and set of attribute values are set to the new object. FullID of the created object is returned.
 

Synopsis:

 

string CreateObject(string sessionId, string namespaceId, string objectTypeName, string name, string parentIds, string[][] attributes, string options)

 

Return Value:

 

FullID of the created object as string.

 

Parameters:

 

sessionId: String. ID of an authenticated session.

namespaceId: String. ID of the namespace into which the object is to be created. The following namespaces are supported at the moment: UM (User Management System), PO (Portal) and SC.<model ID> (QPR Metrics)

objectTypeName: String. Defines the type of the new object. This needs to be a type name that is supported in the namespace. Also type ID can be used. See the UM Object Functions, SC Object Functions and PO Object Functions sections for a listing of valid type names. Using 0 here with the SC namespace creates the default measure type of element.

name: String. Defines name for the new object. In Portal context this is the same as Header. This option is not applicable for Alert objects.

parentIds: String. A comma-separated list of FullID's of parent objects. In the case this is empty and the namespace is PO, the Portal Discussion view is used as the parent. For the SC namespace valid options depend on the type of the created object:

Measure: If the FullID points at a scorecard, the top element of that scorecard is used as the parent element. Only one parent element is supported in this case.

Scorecard: Maximum of one scorecard ID. In the case this is empty, the scorecard will be created under the root level of the model.

SecondaryElement: If the FullID points at a scorecard, the top element of that scorecard is used as the parent element (only one parent element supported). Parent will be set as the owner of the secondary elements.

Alert: If the FullID points at a scorecard, the alert will be created for the top element of that scorecard. Alerts can have only one parent element

InformationItem: One or more measures or scorecards. References to a scorecard will be converted to point at the scorecard's top element.

attributes. A jagged two-dimensional array of strings. Each row in this array needs to contain an attribute name and the value assigned to the given attribute.

options: String. A comma-separated list of options for creating the new object. Available options depend on the product and the object type. In addition, the following option is specifically supported by CreateObject:

ClearParents: true | false. This attribute can be used to force the new object to be created without parent objects in the case the object type supports objects without parent objects. This option is not supported in the SC namespace.

Series: FullID. When an alert is created (in the SC namespace), this option needs to be supplied and contain the ID of the series the alert is attached to.

 

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, "");

MessageBox.Show("Created object with ID " + objectId);

client.LogOff(sessionId);

client.Close();