function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

checking lookup filed value in validation rule

i have 2 objects namely objA,objB.
i have created lookup relationship on objB to objA. objA have some values like abc,xyz(two record names).

here i want to write a validation rule on objA.

While creating objB records when i select abc record from objA i want to make one field mandatory in objB.when i select another record that is xyz record i dont want to validate that field.

i hope im clear with my question.


Write a small trigger checking the value of the lookup field and if the value is 'abc' then put .addError message if the user makes the field to be kept as mandatory empty.

Also, Using normal Customizations, If you check the field to be made as mandatory and the lookup field, you can create a validation rule & validate.

Important :

If this is what you where looking for then please mark it as a solution for others benefits.

Thank You
You can also do this with a validation rule on objB. I don't know your exact field names, but the rule criteria might look something like this:

AND(objA__r.Name = "abc", ISBLANK(Mandatory_Field__c))