How to filter out certain records based on a join / add-on

Options
dorian
dorian Member
edited May 2023 in ? Working with APIs

Hi there

I'm a noob so please forgive what is likely a basic question.

Refer to the attached images. I am trying to create an API that will return all Users that do not have a subsidy for an input business_id. As you can see, each subsidy record has both a user_id and a business_id.

My API is getting all Users fine, and I am able to create an add-on that returns all subsidies for each user. But I can't figure out how to then filter out users that already have a subsidy for the input business_id.

I basically need to filter our user records where subsidies.business_id = the input business_id.

Any help appreciated!

Thanks.

Best Answer

Answers

  • dorian
    dorian Member
    Options

    I tried the 'Array: Find All Elements" function, but getting an error:

  • Pawel Magdanski
    Pawel Magdanski Member ✭✭✭
    Options

    One thing is that you join two tables in you query via join feature, then you will be able to use it in your custom conditions.

    Regarding you error try to use get filter on business_id:

    in condition it should look like this. $this.subsidies → get filter → business_id

    This way even if the subsidies list is empty and there is no path to business id it will not throw and error