Task 2 – Get Versions of an ElementGroup
By the end of this task, you will be able to:
- Fetch versions for a particular elementGroup.
- Make sense of the options and fields in the documentation on the elementGroupAtTip query, elementGroup object, and history / versions object.
You will use the following queries in this task:
Type | Operation | Description |
---|---|---|
Query | elementGroupnAtTip | Retrieves elementGroup at tip. |
Step 1: Request for a particular ElementGroup
The elementGroupnAtTip query returns a ElementGroup object. The ElementGroup object contains an array of elements objects. For this exercise, we request the name
field and the entire history object of the elementGroup.
- In the AEC Data Model Explorer, the query is populated by default in the Query Pane. You can also edit or update the query as per your requirement and run it.
Query
query ($elementGroupId: ID!) { elementGroupAtTip(elementGroupId: $elementGroupId) { id name alternativeIdentifiers { fileUrn fileVersionUrn } versionHistory { versions { results { versionNumber createdOn } } } } }
Show More
- In the Query variables pane, set the variable as the elementGroup ID value obtained in the previous task.
Query Variables
{ "elementGroupId" : "YWVjZH42SUpGQXdONExWTG5JZXZiQk5GNU1IX0wyQ35yRWRKT0NPcVIwZWt5SkJCWWxSOUVB" }
- Click Play. All the previously published versions of that elementGroup will be displayed in the response. The response should be similar to the following code-block:
Response
{ "data": { "elementGroupAtTip": { "id": "YWVjZH42SUpGQXdONExWTG5JZXZiQk5GNU1IX0wyQ35yRWRKT0NPcVIwZWt5SkJCWWxSOUVB", "name": "Snowdon Towers Sample Architectural.rvt", "alternativeIdentifiers": { "fileUrn": "urn:adsk.wipprod:dm.lineage:rEdJOCOqR0ekyJBBYlR9EA", "fileVersionUrn": "urn:adsk.wipprod:fs.file:vf.rEdJOCOqR0ekyJBBYlR9EA?version=1" }, "versionHistory": { "versions": { "results": [ { "versionNumber": 1, "createdOn": "2024-06-18T12:59:46.718Z" } ] } } } } }
Show More
After working through the steps mentioned above, you should see a screen similar to the following image: