Complex question re: Things and Geographical location

Hi,

I hope the following makes sense…

I have a Vault (Thing) that has a field ‘Address’ (type: geographical address).

I have a Task (Thing) that also has a field ‘Address’ (type: geographical address).

A Notification (Thing) is created on the back of a Task created by a “non-host User” (see below) that includes some details from it.

A User is either a “host” or Not (identified through a field)…

  • I have created a relationship between User and Vault through a field (list) called ‘Vaults’ of type Vault in User.

  • I have also created a relationship between user and Notifications through a field (list) called ‘Notifications’ of type Notification.

What I want to achieve is the ability to only display a notification to a User (Host) where the Task (Address) is within eg; 10km from the Vault (Address)…

how can I achieve that?

thank you

What is the trigger to display the notification? When the task is created? That’ll help us figure out what the best approach can be.

Also, can you reproduce the situation in the forum_app? it’d be easier with a real situation in the editor.

Hi,

I have created a page in the the forum app here:

to answer your question, the trigger is when a User (Host) navigates to their “Notifications” they will be shown only those notifications that relate to a Task that was created within say; 10km of the location of their associated Vault location.

Just to put more context to this…

A geograhical area may be serviced by many Hosts (User) which is associated by the location of their Vault (thing).
So, the idea is that when a task is created (by a non-host) that falls within their serviced area, all those applicable Hosts only would be able to see this Notification (eg; Task detail) with an opportunity for them to Accept or Reject the task.

I think you have made life a little hard for yourself with the “Notification” datatype. It doesn’t link to a task (because type is a text not a task) so it is going to be hard to navigate easily.

Maybe if we start off simple and try to display Tasks that are within 10km of the Vault address.

That should be possible, as long as you can point to a single address for vault (so the User has a single vault, or chooses from a list).

What would be quite difficult would be a list of vaults, and asking “show me any task with an address within 10km of any of the vaults in this list”.

1 Like

Hi @NigelG

thanks for your help…I have tried to follow your simplified suggestion above…

With a Vault (address) and Task (Address)…

I have created a Repeating Group of Type: Task (see below)

In the a text element (for testing purposes) I am trying to display the Type using the following but I am getting unstuck with the search query.

I have made some progress…

I have two Tasks with Address in two separate states, so they are well apart from an Address (location) stand point.

I have setup the following workflow which should only display Tasks within 10miles of the Host (Current User) Vault’s Address…

but it is still displaying both even though they are well over 10 miles apart - any ideas?

Can you please confirm the addresses are indeed what you think they are (for the tasks and the user’s vault) using the debugger? Run Step by step and you’ll be able to inspect each value at runtime.

@georgeciobanu

I was able to achieve what I was aiming for. I specified two separate queries and merged them at the the Repeating Group level.

A question though, how can I now sort the merged list? applying the sort applies it to each list individually, thus it lists the results in order followed by the next list result.

1 Like

Can you add the :sorted filter?

Thank you - that’s worked! :slightly_smiling:

@georgeciobanu

In the following scenario, ‘Box_Qty’ is = 2

In action as shown on the screenshot below, I am counting the List of ‘Boxes’ and comparing that to the ‘Box_Qty’ in Task.

eg; IF the list of Boxes count is 0, 1 or 2, THEN I am creating a new Box thing and adding to ‘Boxes [List]’ ELSE do nothing.

The issue I have is that the criteria belows ALWAYS allows for the creating of an extra record, eg; if Qty = 2, it allows to save a third one, if Qty = 3, it allows to write a fourth one before doing nothing…why is that the case?

could it be the case the :count start from 0?

Hi Rogelio,

Apologies for the late reply. As a first step, please use the debugger and run this step-by-step, then inspect the Box counts (by clicking on them while paused) to make sure the values you see are what you expect.

Let me know if that provides any further insights, glad to help if still unclear.

Thanks @georgeciobanu

I figured that I should be using the operand ‘<’ (less than) instead of ‘<=’ (less than and equal to) and that’s worked.

:slightly_smiling:

1 Like