# Relationship dropdown edit widget filter - how to filter dataset based on current entity

**URL:** <https://community.forestadmin.com/t/relationship-dropdown-edit-widget-filter-how-to-filter-dataset-based-on-current-entity/3752>\
**Category:** Help me!\
**Created:** [November 22, 2021, 7:46pm UTC](https://community.forestadmin.com/t/relationship-dropdown-edit-widget-filter-how-to-filter-dataset-based-on-current-entity/3752 "2021-11-22T19:46:11Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![anon34731316](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@anon34731316](https://community.forestadmin.com/u/anon34731316)\
**Post date:** [November 23, 2021, 11:17am UTC](https://community.forestadmin.com/t/relationship-dropdown-edit-widget-filter-how-to-filter-dataset-based-on-current-entity/3752/2 "2021-11-23T11:17:25Z")

</div>

Hello @kll,

Thanks for reaching out!

If I understood well your use case, there is unfortunately no way to fix this in the UI.  
However, it should be doable and not too complicated to do it in the code, overriding your GET route to `band` and using the `request.query.context`.

Something like this:

```javascript
router.get('/bands', permissionMiddlewareCreator.list(), async (request, response, next) => {
  if (request.query.context.record.type === 'bandMember') {
    const bandMember = await bandMembers.findByPk(request.query.context.record.id, {
      include: [{ model: concerts, attributes: ['id'] } ]
    });
    const bandMemberConcertIds = band.concerts.map(concert => concert.id);

    const foundBands = await bands.findAll({
      where: {
        concertId: { [Op.in]: bandMemberConcertIds }
      }
    });
    const serializer = new RecordSerializer(bands, request.user, request.query);
    response.send(await serializer.serialize(foundBands));
  } else {
    next();
  }
});

```

Let me know if this helps!  
Thanks.

---

_[View the full topic](https://community.forestadmin.com/t/relationship-dropdown-edit-widget-filter-how-to-filter-dataset-based-on-current-entity/3752)._
