Skip to main content

I am trying to create a validation rule where users can not create a new Event Object if a checkbox is checked on a field on the Contact object. They are different Objects, so I was unable to grab the field in the validation rule. But the "Create New Event" form is on the Contact Object page.

Any ideas on how to achieve this?

 

Prevent Creation of Event Object on Service Cloud with an Inactive Checkbox Field on Contact Object

 

#Service Cloud

1 个回答
  1. 9月2日 21:35

    Yes, this is possible if the Event has a relationship to the Contact that you're creating the Event from.

    In Salesforce, validation rules can reference fields on a parent record through a cross-object formula. Salesforce supports cross-object validation rules using relationship fields.  

     

    For example, if your Event is related to a Contact through WhoId

    (standard Activity relationship), you may be able to reference the Contact checkbox in a validation rule on Event. 

     

    Example:

    AND(

    ISNEW(),

    Who.Contact_Inactive__c

    )

    Things to check

    1. Does the Event actually have the Contact populated when the validation fires?
      • If users click New Event from the Contact record page, Salesforce typically populates the Contact relationship automatically.
    2. Can you see the Contact field in the formula editor?
      • In the validation rule formula editor, click Insert Field and look for the relationship path (often under Who for Contacts/Leads).
    3. If the checkbox field is not accessible through a relationship path
      • You may need a before-save Flow, record-triggered Flow, or Apex trigger to prevent creation instead.
0/9000