# Button Howto: Link task to other object (relation)

**URL:** <https://community.fibery.io/t/button-howto-link-task-to-other-object-relation/1411>\
**Category:** API & Programming\
**Created:** [March 1, 2021, 12:15pm UTC](https://community.fibery.io/t/button-howto-link-task-to-other-object-relation/1411 "2021-03-01T12:15:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndreasHe\_daic](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@AndreasHe\_daic](https://community.fibery.io/u/AndreasHe_daic)\
**Post date:** [March 1, 2021, 12:15pm UTC](https://community.fibery.io/t/button-howto-link-task-to-other-object-relation/1411/1 "2021-03-01T12:15:39Z")

</div>

Wanted a button to assign a team to a task when clicking the button. Got the following solution:

```
for (const entity of args.currentEntities) {

    const team = await fibery.getEntityById("Team", "4524be10-7a6a-11eb-8005-e144590b652c",["Id"]);

    // to update an entity provide an object with the new values
    
    await fibery.updateEntity(entity.type, entity.id, {
        'Team': team["id"]
    });
}

```

The UUID I got by scanning network traffic. Is there an easier way to determine it?

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [March 1, 2021, 7:45pm UTC](https://community.fibery.io/t/button-howto-link-task-to-other-object-relation/1411/2 "2021-03-01T19:45:27Z")

</div>

try something like this:

```
const fibery = context.getService('fibery');
const Anything = await fibery.executeSingleCommand({

    "command": "fibery.entity/query",
    "args": {
        "query": {
            "q/from": "Your_app_name/your_type_name",
            "q/select": [
                "fibery/id",
                "Your_app_name/Name"
            ],
            "q/where": ["=", ["Your_app_name/Name"], "$search_name"],
            "q/order-by": [
                [["Your_app_name/Name"], "q/asc"]
            ],
            "q/limit": 1
        },
        "params": {
            "$search_name": "Name_to_find"
        }
    }
});

return Anything[0]["fibery/id"])

```

It should return the ID of the first entity of Type ‘your-type-name’ in App ‘Your\_app\_name’ which has Name = “Name\_to\_find”.

There may be other easier ways, and apologies for any coding errors…

---

<div class="post-metadata">

**Author:** ![Dimitri\_S](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/dimitri_s/32/1683_2.png) [@Dimitri\_S](https://community.fibery.io/u/Dimitri_S)\
**Post date:** [December 9, 2021, 2:36pm UTC](https://community.fibery.io/t/button-howto-link-task-to-other-object-relation/1411/3 "2021-12-09T14:36:58Z")

</div>

Trying to use this and I’m getting the error message: `Each param should have database.`

Here is the example request I am making:

```auto
{
    command: "fibery.entity/query",
    args: {
      query: {
        "q/from": "my_space/my_db",
        "q/select": ["fibery/id", "my_space/Name"],
        "q/where": ["=", ["my_space/Name"], "$search_name"],
        "q/limit": 1,
      },
    },
    params: {
      $search_name: "John Smith",
    },
  }

```

In Postman:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/c/c4888b2a2a5a0d938f6bb5d34a4d11a38b0bc7c3.png)

Also paging @Oleg or @Sergey_Truhtanov 👆

---

<div class="post-metadata">

**Author:** ![Andray\_Shotkin](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/andray_shotkin/32/1531_2.png) [@Andray\_Shotkin](https://community.fibery.io/u/Andray_Shotkin)\
**Post date:** [December 14, 2021, 4:15pm UTC](https://community.fibery.io/t/button-howto-link-task-to-other-object-relation/1411/4 "2021-12-14T16:15:11Z")

</div>

Hi!  
`params` key should be under `args` key.  
So the structure should be following:

command:  
args: {query, args}

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [December 15, 2021, 9:08am UTC](https://community.fibery.io/t/button-howto-link-task-to-other-object-relation/1411/5 "2021-12-15T09:08:20Z")

</div>

Is this any use?

> [@Command methods for button, and/or token availability in context](https://community.fibery.io/t/command-methods-for-button-and-or-token-availability-in-context/1035/3):
>
> Nice! I can’t find executeSingleCommand anywhere in the API docs, but I assume the IntelliSense in the button editor will help and/or that it takes the entire payload that would normally go in to body? The other stuff isn’t a huge deal for me, so no worries about that. slight_smile EDIT: Indeed it shows up in the IntelliSense, and it takes the body payload—except you omit the wrapping array and leave it with 1 command (as the method name suggests). For other people’s reference, here’s an ex…
