How do you find if a value is present in a table ref
I have a table Customers with a 1-n relation to contacts. The contact table contains the user field access.
How can I check if current user is one of the contacts defined in customers.contacts.access
Thank you
Jesper
https://ninox.com/en/manual/calculations/reference-of-functions-and-language
5 replies
-
To elaborate further. The idea is to be able to show if the current user is related to the customer.
Tables
Customers
Contacts - relates to Customers. Contains a field "access" that is of type "user".
Projects - relates to Customers
How can I show a field on a project that show if current user is related to the Customer?Ive tried aggregated functions but theres only a few: first/last/concat/count -which doesnt bring me further.
I would think that I should make some sort of
select Customers.Contacts where access = user()
Or something that works with array?
Thank you
Jesper
-
As I understand it the select is doing a table lookup unlrelated to the current so in the example I made here it would also require adding a relation to which customer I need contacts from. maybe the more "correct" approach is to do something with the collection that is received.
If I in the formular reference Customers.Contacts.access and concat it it shows only the users related to this customer. But how do I query this ? -
I found a solution. Please let me know if this is the optimal:
let ret := false;
for contact in Customers.Contacts.access do
if contact.User = user() then ret := true end
end;
retThank you
Jesper
-
Do you tried one request like that ?
count(Custmer.Contacs.access where User = user())>0; => return true if count is > 0.
-
Thanks Jacques - that was much faster :-)
Content aside
- 3 yrs agoLast active
- 5Replies
- 621Views