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
Lloyd RuzLloyd Ruz 

Validation rule for custom objects

I have two custom objects the work in the following way:

ENROLMENTS (Custom) are child objects to COURSES (Custom) and CONTACTS.

I want to make a validation rule that doesn't let users check a checkbox field on a COURSE if a CONTACT who has an ENROLMENT on that course doesn't have an email address. I tried doing this by making an ENROLMENT validation rule (below) but it didn't work (i.e. I was still able to check the box even though there was an enrolment that should have made this impossible).

AND( ISBLANK( Contact__r.Email ),  Course__r.Send_Pre_Work__c = TRUE)

Any ideas as to why this didn't work?
sachin kadian 5sachin kadian 5
Hi Lloyd,

If you want a validation on COURSE object , you need to make the validation rule on COURSE object only. if you will create validation rule on ENROLMENT, it wont work. however from your question i understand ENROLMENT is just like a junction object here. so instead of validation rule, you will have to create trigger. 
Lloyd RuzLloyd Ruz
Hi Sachin, We don’t have the functionality to create triggers. Is there no way of doing this through validation rules? For some reason the course object doesn’t allow validation rules based on enrolment information. Lloyd Ruz Sales and Marketing Coordinator Scotwork Australia 210/410 Elizabeth Street | Surry Hills | Australia | 2010 www.scotwork.com.au Tel: 02 9211 3999 [Web small celebrating 40 years since 1975 FINAL]
sachin kadian 5sachin kadian 5
Hi Llyoud,

When you are writing validation rule on any object, you can refer its parent record only not the child records.  means lets say if there are 2 objects objP(parent) and objC(child) then if you will write the validation rule on objC, you would be able to refer the objP fields but if you will write validation rule on objP,you wont be able to refer objC's fields. Here in your case, if i am not wrong, COURSE is master object of ENROLMENT so you wont refer its fields.