Using webhooks to search for records

Hey @fernando.nakandakari can you help giving us a tip in how to do it?

Hey there :wave:

In Jestor’s low code area, you can create functions and then create webhooks for that specific function. This means when you send information to that webhook, it will run this data through the function and do whatever you want.

So imagine I have a table called Projects and have this scenario:

  1. I want to send the project name and a budget value to the webhook;
  2. Jestor searches for projects with that name and updates the first result;

So first I would go to the low-code area and go to Back-end functions.

image

Then, I’d create a function with the following code:

$search = Jestor.loadData('projects',['where' => ['name' => $data['name']]]);
Jestor.update('projects',['id_projects'=>$search[0]['id_projects'], 'budget' => $data['budget']]);

Then, I’d go to Webhooks and create an active Function webhook to this function I just created.

Now, I can just send data to this webhook URL and it’ll run through this function. In the example below, I passed name = Podcast and budget = 500.

Before:

image

After:

image

This is a very simple example. Webhooks can have any sort of logic you want, including complex searches or even trigger outward API calls. It just depends on the code of the function :slight_smile:

2 Likes