Validation for empty field in related module before save

I am looking to create a point of validation before a save. I have a custom module called Sample Requests and when a salesman selects an account(Relate Field) to make a sample request for, I would like for them to be unable to save a new sample request based on whether that account has the primary address field filled or not.

Does anyone know how to do this? Looking into it, I get very confused because I cant find a working example. Thank you.

@Chris0002
You can look at this post:


It is dynamically changing validation for field.

Another way will be to add a before save logichook to check if the required fields are not empty. Then proceed to save. If not. You can redirect yout URL to what ever module/page you want.

Thanks,

BrozTechnologies

True, I will try this. I’m just not sure how I could write that. For example where can I state to check for a field within that related module. In my custom module id have to have a check for whether or not that Lead that is selected has the primary_address_street field filled or empty.

If someone could help me with example code for this, it would be greatly appreciated.

First. To create logichooks you need to have some programing experience. It requires creating and modifying files in the back end.

Here is the documentation related to logic hooks:

Then you need to learn to work with beanns to load the related account bean from your logichook:

Check this sample. The last post seems to be related to your issue:

Here is a sample on how to redirect from logichooks:

Thanks,

BrozTechnologies