Get_full_list with field relate

Hello everyone, I will briefly explain the problem.
I have a subpanel inside a form (both custom), when I create a new record from the subpanel, I insert data into the fields, among them there is also a relate field.
What I would like is to check in real time the existence of the entry, the record already exists if 2 fields are equal:

ID field
Related field

I don’t have any problems with validating normal fields, but I need an idea to check the existence of the related field, as it is not part of the table and I don’t know how to do the check. Something like this:

$bean= BeanFactory::getBean('<Module>');
			$beanList = $bean->get_full_list(
							//Order by the id
							id',
							"id = '".$id."' AND deleted = 0 AND <related_field>='".$related_field_value."'"
							);

Do you have any suggestions? Thanks in advance

I have read some people have done with a mix of Ajax and javascript but haven’t done myself. What you might be able to do is to create a before save logic hook where you validate the fields and if it already exists, you can decide what action to take.

I have already done the validation, everything works, the problem is the related field which is not part of the module in question, I was hoping that there was something more immediate via the Suite bean.
At the moment I’ve solved it by querying the DB via SQL, it’s not elegant, but it works, if there is something that allows you to use Suite’s functionality I’d love to know about it.
Thank you.