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
Thato SitholeThato Sithole 

CREATE VALIDATION RULE

Hi, all I am currently dealing with the create a validation rule challenge and my error keeps coming back the same it reads:  We can't create a contact by itself (without an associated account). Make sure the validation rule applies ONLY when the contact. Please help, 
CharuDuttCharuDutt
Hii Thato 
Try Below Code
Validation Rule

AND(ISNEW() , ISBLANK( AccountId) )


OR

trigger TestTrigger on Contact (before insert) {

    for(Contact Con: trigger.new) {
        if(Con.AccountId== null){
            Con.AddError('Can't Create Contact Without Account Assosiated');
        }  
    }
}

Please Mark It As Best Answer If it Helps
Thank You!
Maharajan CMaharajan C
Hi Thato.

Are you looking for the below Validation Rule Which is on trailhead challenge?
 
AND(
    NOT(ISBLANK( AccountId )),
    MailingPostalCode  <>  Account.ShippingPostalCode
)

Thanks,
Maharajan.C
Thato SitholeThato Sithole
i am looking for that, although when ever i check the challenge it give me the error of We can't create a contact by itself (without an associated account). Make sure the validation rule applies ONLY when the contact.