# Query rows via API

**URL:** <https://community.glideapps.com/t/query-rows-via-api/75092>\
**Category:** Ask for Help\
**Tags:** api\
**Created:** [July 22, 2024, 10:56pm UTC](https://community.glideapps.com/t/query-rows-via-api/75092 "2024-07-22T22:56:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![evazivanovic](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/evazivanovic/32/83692_2.png) [@evazivanovic](https://community.glideapps.com/u/evazivanovic)\
**Post date:** [July 22, 2024, 10:56pm UTC](https://community.glideapps.com/t/query-rows-via-api/75092/1 "2024-07-22T22:56:50Z")

</div>

Hey guys,

I’m using Make to run an automation and I am having trouble querying the data. I think this could probably be done without Make too, but that’s not the point.

Here’s the use case:

- The user submits an absence. This absense should be linked to the right annual leave record.
- If the annual leave record does not exist, it should create a new one if it fits certain conditions.

Here’s an example.

Josh has an annual leave of 25 days which renews yearly on Jan 1st. This leave is always valid from Jan 1st to Dec 31st.

However parental leave is valid from the day the parental leave absence is submitted.

So if I submit parental leave today, and I don’t have an active parental leave record currently, a new one should be created with validity until July 23rd 2025.

So basically I am using a few different filters:

- user email
- absence type
- leave dates

I don’t want to iterate through the entire table, I would just like to search for records that fit my criteria.

How can do that?

I hope that wasn’t too confusing

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [July 22, 2024, 11:33pm UTC](https://community.glideapps.com/t/query-rows-via-api/75092/2 "2024-07-22T23:33:59Z")

</div>

So your data would look something like this?

1. Annual Leave Records:

| id | user\_email | leave\_type | total\_days | start\_date | end\_date |
| --- | --- | --- | --- | --- | --- |
| L0001 | [josh@example.com](mailto:josh@example.com) | annual | 25 | 2024-01-01 | 2024-12-31 |
| L0002 | [josh@example.com](mailto:josh@example.com) | parental | 365 | 2024-07-23 | 2025-07-22 |

1. Absences:

| id | user\_email | absence\_type | start\_date | end\_date | annual\_leave\_record\_id |
| --- | --- | --- | --- | --- | --- |
| A0001 | [josh@example.com](mailto:josh@example.com) | annual | 2024-08-01 | 2024-08-05 | L0001 |
| A0002 | [josh@example.com](mailto:josh@example.com) | parental | 2024-07-23 | 2024-08-22 | L0002 |

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [July 23, 2024, 2:26am UTC](https://community.glideapps.com/t/query-rows-via-api/75092/3 "2024-07-23T02:26:19Z")

</div>

> [@evazivanovic](#):
>
> I don’t want to iterate through the entire table, I would just like to search for records that fit my criteria.
> 
> How can do that?

You can’t, unless the source table is a Big Table.

But looking at your description, I don’t think you need the API. You should be able to handle all the logic within Glide (I suspect that’s where @ThinhDinh is going with his clarifying question).

---

<div class="post-metadata">

**Author:** ![evazivanovic](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/evazivanovic/32/83692_2.png) [@evazivanovic](https://community.glideapps.com/u/evazivanovic)\
**Post date:** [July 23, 2024, 6:41am UTC](https://community.glideapps.com/t/query-rows-via-api/75092/4 "2024-07-23T06:41:18Z")

</div>

@ThinhDinh close but not quite. The structure overall looks correct, though, yeah

The parental leave depends on the number of children the employee has under 12 years of age (norwegian legislation). It could 10 days it could be 12 etc.

So basically what I need to do is:

1. Check the type of leave request
2. Check if parental leave record exists
3. If not, check how many children under 12 the employee has
4. Create a leave record with validity of 365 days and add the respective number of available days to the record
5. Link the leave request to parental leave record

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [July 24, 2024, 12:28am UTC](https://community.glideapps.com/t/query-rows-via-api/75092/5 "2024-07-24T00:28:58Z")

</div>

I think you would have to create a custom form for that.

> [@How do I create a custom form?](https://community.glideapps.com/t/how-do-i-create-a-custom-form/25014):
>
> I’m just dropping this here so I have something to refer people to when they ask. This is a simple concept app (copyable), that demonstrates the following techniques: Building custom forms for adding and editing list items (as an alternative to the native forms provided by Glide) Preventing duplicate new entries using [User Specific Columns](https://docs.glideapps.com/all/reference/data-editor/user-specific-columns) and [Relations](https://docs.glideapps.com/all/reference/data-editor/computed-columns/relation-column) Enforcing mandatory input items The use of visibility conditions and user specific booleans to control user flow There is nothing particular…

- Create an If-Then-Else column in your User Profiles table called “Parental leave days”. If “children under 12” is over X, then 12 days, else 10 days, structure your logic around this part.

> [@evazivanovic](#):
>
> The parental leave depends on the number of children the employee has under 12 years of age (norwegian legislation). It could 10 days it could be 12 etc.

- Back to your custom form’s helper table, you should have user-specific columns to hold the user’s type of leave request.
- Create a query column targetting the parental leave records table, filter by the user’s ID/email, and the type of request being the same as the one in your form.
- Have a submit button in your form. Have a custom action with as many branches of logic as you need. One should be “If query column is empty”, then add a parental leave record, before adding a leave request. Else just add the leave request.
