QPR Knowledge Base 2016.1

CreateCopy

CreateCopy

Previous topic Next topic No directory for this topic  

CreateCopy

Previous topic Next topic Topic directory requires JavaScript Mail us feedback on this topic!  

Revision history:

Introduced in QPR 8.1

 

Creates a copy of QPR object(s) defined by objectIds and sets the new object's parents. Various attributes can be supplied to the created object in the attributes parameters. The options attribute can be used for instance to include hierarchies in the copying operation. The function returns ID's of created objects as a comma-separated list.Returns the new created object's Ids as comma separated list.

 

Synopsis:

 

string CreateCopy(string sessionId, string objectIds, string parentIds, string[][] attributes, string options)

 

Return Value:

 

Comma-separated list of FullID's of created objects.

 

Parameters:

 

sessionId: String. ID of an authenticated session.

objectIds: String. A comma-separated list of objects to be copied. Note that only scorecards, measure elements, linked elements, information items, and alerts can be copied.

parentIds: String. A comma-separated list of FullID's of parent objects for the created copies. If this is empty, the default parents are used (e.g. for Actions in the PO namespace the default parent is the Discussion view in Portal). For the SC namespace valid options depend on the type of the copied 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.

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 options are specifically supported by CreateCopy:

ClearParents: true | false. This attribute can be used to force the copy 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.

Recursive: true | false. If this is true, also child objects are copied. By default this is false. In the SC namespace this is valid only for measures.

KeepOriginalParents: true | false. If this is true, the parents in parentIds parameter will be added to the list of parents of the original object. This option is not supported in the SC namespace

AsReference: true | false. If this is true, the copy is created as a reference elements. The default value is false, which creates normal copies. Note that in the case this is true and also Recursive is true, then all elements are created as reference elements. This option is supported only in the SC namespace.

 

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

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

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

MessageBox.Show("Created a copy of " + objectId + " with ID " + copiedObjectId);

client.LogOff(sessionId);

client.Close();