IF and SELECT in templates

Hi, how can I work with different tables in a template?

Example I have thes three tables, one with customers, other with relations between Customers and other with Sales:

Customers
document(pk)
name
lastname
dob
age

Relations
id_relation(pk)
document1(pk_Customers)
document2(pk_Customers)
tutor(Y/N)

Sales
id_sales(pk)
customer(pk_Customers)

Template grow from Sales table.

In the template i need to indicate โ€œYESโ€ if the person is under 18 or โ€œNOโ€ if the person is 18 years or older. And if customer is under 18 display the data of the Customer who have tutor attribute on YES(there will be only one with this condition).

I tryed with: <<IF:SELECT(Customers[age],[document]=[customer])<18>>โ€œYESโ€<<endif>> and didnยดt work.

Alone SELECT(Customers[age],[document]=[customer]) display the age data correctly.

For the second step, if the result of condition was โ€œYESโ€ show the Customers data who is tutor, iยดm lost.

Thaks comunity!

0 4 200
4 REPLIES 4

The IF condition is not in proper syntax. You need to wrap the SELECT() with an ANY() function like so:

<<IF:ANY(SELECT(Customers[age],[document]=[customer]))<18>>โ€œYESโ€<<endif>>

EDITED: Corrected so that endif would show. Thanks @Steve !!


I would recommend reviewing these articles for more details about working in tempaltes.

And this Support Search will provide several others that might be of interest:

https://www.appsheet.com/Support?q=templates&hPP=10&idx=help&p=0&is_v=1

Hi, it was easier, i wasn`t familiar with โ€œdereferenceโ€. Solution was:
On sales table:
<<IF: [customer].[age]<18>>YES<>

But, ยฟhow many dereferences can be nested?

Still working on the second step.

Thanks!

Nested dereferences were recently introduced. What limit is there? Iโ€™m not certain and donโ€™t recall it documented.

If by โ€œnestedโ€ you mean โ€œchainedโ€ (e.g., [a].[b].[c]), I believe three is new limit, but it should be easy enough to test longer chains and find out.

Top Labels in this Space