Agile Central - Queries: Is there a way to know if an artifact was created by a Copy of another?

Document ID : KB000115495
Last Modified Date : 20/09/2018
Show Technical Document Details
Question:
Can we know if an artifact was created by a Copy of another?  If so, how?
What if we wanted to get all artifacts that were created by Copy or perhaps just the Defects, is that possible?
Answer:
The 'Copy' action itself is not registered. There isn't a way to find out if any artifact was a source of a copy or if a copy action was taken. There is nothing at all that's registered for the source artifacts, no revision is made or other indication it was ever copied. The new artifact (the clone) has an indication was created but nothing that necessarily is the evidence it was by copy. Similarly, if an artifact is created by Template there isn't any indication it was created by the template. The Copy Action itself is not logged.

We can, however, find the 'fingerprint' of this action and deduce it was taken. 

1. For an individual artifact:
The newly created clone artifact will have a Name change indication in its very initial revision. Immediately following the Original revision (revision #0) there will be a Name Change revision that reads:

"Name changed from [(Copy of)... original artifact's name] to [new name...]", see this screenshot below:

User-added image

This indication is logged even if you change this name string and rename your new artifact in your original copy. The "fingerprint" therefore is this string (Copy of).

One way to figure out if an artifact was made by copy is to pull up the revision history of this artifact and check for this Name Change indication in revision #1. This method requires you know the new artifact obviously.

Keep in mind, if someone creates an artifact from scratch (not by copy) and name it with a convention starting with (Copy of) then it will look just as this. As said, there isn't an actual logging of the action (whether created from scratch or by copy).

2. For multiple artifacts:
The above method is good for an individual artifact. What if you wanted to get all artifacts made by Copy, or perhaps only Defects made by Copy?   The above method won't apply.

For that you can use the Lookback API and issue a query to locate that 'fingerprint' - an initial revision upon creation that has a Name Change from (Copy of). Here are two examples: 

a. This query that will retrieve all/any artifacts that have the '(Copy of)' fingerprint: 
{$and: [{"Name": {$regex: "^\\(Copy of\\)"}}, {"_SnapshotType": "CREATE"}]} 

b. This query will retrieve any/all Defect artifacts that have the '(Copy of)' fingerprint:: 
{$and: [{"Name": {$regex: "^\\(Copy of\\)"}}, {"_SnapshotType": "CREATE"}, {"_TypeHierarchy": "Defect"}]} 

You can further issue similar queries using the Lookback API to further narrow down your search based on that 'fingerprint'.
Additional Information:
More articles on Lookback API: https://support.ca.com/us/product-information/ca-agile-central.html?type=ALL&q=%22Agile%20Central%20-%20Lookback%22