> For the complete documentation index, see [llms.txt](https://developer.collibra.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.collibra.com/api/guides/introduction/the-output-module-query-language/add-a-related-entity-more-than-once.md).

# Add a related entity more than once

To understand what roles users have in communities, you must query the groups that are linked through a responsibility.

To add another relation from community to responsibility, select the related groups.

This example shows the `Id` property of the two-responsibility nodes selected.

{% tabs %}
{% tab title="JSON" %}

```json
{
  "ViewConfig": {
    "Resources": {
      "Community": {
        "Id": { "name": "communityId" },
        "Name": { "name": "communityName" },
        "Responsibility": [
          {
            "Id": { "name": "userResponsibilityId" },
            "User": {
              "Id": { "name": "userId" },
              "FirstName": { "name": "firstName" },
              "LastName": { "name": "lastName" }
            },
            "Role": {
              "Signifier": { "name": "userRoleName" }
            }
          },
          {
            "Id": { "name": "groupResponsibilityId" },
            "Group": {
              "Id": { "name": "groupId" },
              "GroupName": { "name": "groupName" }
            },
            "Role": {
              "Signifier": { "name": "groupRoleName" }
            }
          }
        ]
      }
    }
  }
}
```

{% endtab %}

{% tab title="YAML" %}

```yaml
---
ViewConfig:
  Resources:
    Community:
      Id:
        name: "communityId"
      Name:
        name: "communityName"
      Responsibility:
      - Id:
          name: "userResponsibilityId"
        User:
          Id:
            name: "userId"
          FirstName:
            name: "firstName"
          LastName:
            name: "lastName"
        Role:
          Signifier:
            name: "userRoleName"
      - Id:
          name: "groupResponsibilityId"
        Group:
          Id:
            name: "groupId"
          GroupName:
            name: "groupName"
        Role:
          Signifier:
            name: "groupRoleName"
```

{% endtab %}
{% endtabs %}

To add the same related entity twice under the same node, change the JSON object into an array. In this case, the `Responsibility` JSON object became an array, and the anonymous JSON objects composing the array are multiple responsibilities.

If you add the admin group to the second community, the results would be formatted similar to the example below.

```json
{
  "view": {
    "Community0": [
      {
        "communityId": "c87f166e-041f-4bea-8ff7-c1ffbab2ceeb",
        "communityName": "First Community"
      },
      {
        "communityId": "12345678-0020-0000-0000-000000000000",
        "communityName": "Second Community",
        "Responsibility1": [
          {
            "userResponsibilityId": "0ecb2fff-d5de-43d0-be60-f7f201c10d41",
            "User2": [
              {
                "userId": "00000000-0000-0000-0000-000000900002",
                "firstName": "Admin",
                "lastName": "Istrator"
              }
            ],
            "Role3": [
              {
                "roleName": "Admin"
              }
            ]
          },
          {
            "userResponsibilityId": "42b9d114-2c0c-4e96-a1ce-b645d5e92365",
            "User2": [
              {
                "userId": "00000000-0000-0000-0000-000000900002",
                "firstName": "Admin",
                "lastName": "Istrator"
              }
            ],
            "Role3": [
              {
                "roleName": "Steward"
              }
            ]
          },
          {
            "groupResponsibilityId": "5fc0cc5f-e30e-488c-94bc-acdea171219d",
            "User2": [
              {}
            ],
            "Role3": [
              {
                "roleName": "Admin"
              }
            ]
          }
        ],
        "Responsibility4": [
          {
            "userResponsibilityId": "0ecb2fff-d5de-43d0-be60-f7f201c10d41",
            "Group5": [
              {}
            ],
            "Role6": [
              {
                "groupRoleName": "Admin"
              }
            ]
          },
          {
            "userResponsibilityId": "42b9d114-2c0c-4e96-a1ce-b645d5e92365",
            "Group5": [
              {}
            ],
            "Role6": [
              {
                "groupRoleName": "Steward"
              }
            ]
          },
          {
            "groupResponsibilityId": "5fc0cc5f-e30e-488c-94bc-acdea171219d",
            "Group5": [
              {
                "groupId": "4eb1f4a9-14a3-4539-8afc-733925161179",
                "groupName": "admin"
              }
            ],
            "Role6": [
              {
                "groupRoleName": "Admin"
              }
            ]
          }
        ]
      }
    ]
  }
}
```

{% hint style="info" %}
In the example above, the `userResponsibilityId` and `groupResponsibilityId` values contain three unique values in total: two related to a user and one to a group. When no further filtering is requested, adding the same entity twice means selecting the same thing twice. The result is one empty user for the responsibility linked to the group and two empty groups for each responsibility linked to a user.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.collibra.com/api/guides/introduction/the-output-module-query-language/add-a-related-entity-more-than-once.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
