Start a new topic
Answered

Validation rules

Hello,

I have an entity called account in oneToMany relationship with an entity Contact. Each account has about 3 contacts. The contact table has a field called typeContact which is a list of values containing all possible types ('accountant', 'adminstrator',....).

Each account must have only one accountant. I wanted to add a validation rule, to check each time if we have an accountant or not. I started by creating a function in the database that returns a boolean, and adding it as a validation rule, but that didn't work. Can you please help me?

Thank you


Best Answer

Hi Ziyad,


you don't need to create a custom database function for your needs.


Our semQL language provides a lookup syntax that can access children's records and calculate accordingly, like a group by would do in SQL.


For your specific case, you have to create a validation rule on the parent entity that will have this kind of expression:

  

lookup
count
from Contacts
where TypeContact='Accountant'
end
=
1

  

I hope this helps.

Best regards,

Stéphanie.

1 Comment

Answer

Hi Ziyad,


you don't need to create a custom database function for your needs.


Our semQL language provides a lookup syntax that can access children's records and calculate accordingly, like a group by would do in SQL.


For your specific case, you have to create a validation rule on the parent entity that will have this kind of expression:

  

lookup
count
from Contacts
where TypeContact='Accountant'
end
=
1

  

I hope this helps.

Best regards,

Stéphanie.

Login to post a comment