Streamlining Business Processes with Advanced Salesforce Validation Rules

In today’s fast-paced business environment, maintaining data integrity and ensuring efficient workflow management are paramount. Salesforce, with its robust features, allows organizations to enforce business logic and streamline operations through validation rules. These rules not only help in maintaining the quality of data but also guide users in adhering to established business practices.

Here, we’ll explore several scenarios where custom validation rules in Salesforce can significantly enhance operational efficiency and prevent common data entry errors.

Scenerio 1 :- Create a validation rule to restrict user to create opportunity using account which is blacklisted Blacklisted Account are those customer who we cannot sell.

Follow Below Steps:-

Step 1 :- Create a custom field on account called(is Blacklisted) Datatype :- checkbox i.e (if isBlacklisted checkbox is checked it means the record is blacklisted user can’t creat

opportunity using this account.

Step 2 :- Display Error Message to the user “This account is Blacklisted Please contact Finance Department.” ) Or If Checkbox is unchecked that Account is activated.

Screen:- The Account is Blacklisted.

Error for the New Opportunity:

Scenerio 2 :- Opportunities should not be allowed to have a Close Date in the past.

Validation Rule: Implement a validation rule that restricts users from setting the Close Date to a date that has already passed.

Scenerio 3 :- Create a validation rule to restrict users to add discount for the regular opportunity.

Steps:

1. Create a picklist field named “Opportunity Type” on the Opportunity
2. Add values to the picklist like “Regular,” “VIP,” and “Special.”
3. Create a percentage field named “Discount” on the Opportunity
4. Create a validation to restrict the user to add discount for the Regular

4. Display the below error:

“Discounts cannot be applied for regular opportunities. Please consult with the finance department for further information.”

Scenerio 4 :- Create a validation rule on the opportunity to restrict users from modifying the Stream once a product has been added. The validation should be triggered if any

attempt is made to update the Stream field when products are associated with the opportunity.

Example: A customer originally expressed interest in the Science stream and requested training in Computer Science. The user added this stream and its associated product details to the opportunity. However, the customer later changed their preference and wants to take the training of Accounting because due to its high demand in the market. The user tried to change the stream to the commence without removing the existing product. To ensure data remains accurate, we need to restrict user from updating the Stream once a product have added.

Steps:

1. Create a custom object named “Stream” along with its associated
2. Create a rollup summary field called “ProductCount” on opportunity to count the
3. Establish a relationship between the Opportunity and Stream
4. Write a validation for the above
5. Display Error: ‘You cannot change the stream as a product is added to the To Change Department. Delete all the products added to this opportunity.

Scenario 5: Create a validation rule on the opportunity to restrict users from modifying the department once a product has been added. The validation should be triggered if any attempt is made to update the department field when products are associated with the opportunity.

Steps:

1. Create a custom object named ” Department ” along with its associated
2. Create a rollup summary field called “ProductCount” on the opportunity to count the
3. Establish a relationship between the Opportunity and Department
4. Write a validation for the above
5. Display Error: ‘You cannot change the Department as Product is added to the To change Department delete all the Products added to this Opportunity.

Scenerio 6 :- Create a picklist field on the Opportunity object with a category type, and this field should have two values: “Product Opportunity” and “Non-Product

Opportunity.” The goal is to ensure that if a user wants to change an opportunity category from “Product Opportunity” to “Non-Product Opportunity”, if a product is

already associated with that opportunity, it should automatically generate a validation error to prevent users from altering the opportunity’s.

Scenerio 7 :- Create a new picklist value for the Opportunity Stage field called

“Amendment.” Once an opportunity is marked as “Closed Won,” it becomes locked, meaning it cannot be edited by the sales user. if user want to make some changes to opportunity, it should get a validation error Closed Won Opportunities cannot be

materially changed unless set to amendment stage.

Scenerio 8 :- Create a validation rule on opportunity to prevent users from moving an opportunity to the “Amendment” stage if it’s currently in an “Open” stage. This

means that when the user tries to change the stage of an opportunity from any stage considered ‘Open’ directly to “Amendment”, the system will block this action and

display an error. The rule ensures that the “Amendment” stage can only be assigned from the “Closed Won” stage.

Scenerio 9 :- Create a new picklist field on the Opportunity object named “Discount Approval Status” with options such as Ready for Approval, Submitted, Approved, and

Rejected. Create a validation rule to ensure that if the discount approval status is not set to either “Approved” or “Rejected” and a user attempts to change the Opportunity stage to

“Closed Won,” a validation error should occur. The validation rule ensures that opportunities cannot be marked as “Closed Won” unless their associated discount approval status has

been approved or rejected.

Scenerio 10 :- Create a validation rule on Opportunity add a product before moving from the New stage to another stage display an error if product is not added to the record.

Step 1 :- Apply the condition on the opportunity before moving from the stage “New” .The stage should not be changed before adding the product.

Step 2:- Check that the Amount field is not null. (EX: After adding product amount, it will be populated.)

Scenerio 11 :- Creat a validation rule if Opportunity Contract Change Approval Status is

Untill “Approved”. User cannot edit opportunity or add product to the particular opp record.

Step 1 :- Create a Field called “Contract change approval status”.

Step 2 :- Datatype (PickList) Add values (Submitted, Rejected, Approved, Unapproved.).

Step 3 :- Create a condition until Contract change approval status is Approved user cant edit the record.

Error :-

Scenerio 12:- Create a validation rule for the admission date should be in between batch start date and end date.

Steps:

Step1: Create objects Course, Admission, Batch and Student details.

Step2: Add the fields related for all the objects. Like Batch start date and End date on batch object

Step 3: Admission date on admission object also create lookup relation of admission with Batch and course object.

Step 4: Create the validation rule for admission date is in between batch start date and end date.

Error Message: Ensure that admission date fall between the course duration.

Scenerio 13:- Before moving child opportunity to the Contract Approved stage, its Non Contracted parent opportunity must be at the ‘Contract Sent’ stage but the opportunity type must be non-contracted

Step 1:- Create Selflookup self-lookup relationship. On opportunity. (The record which is holding another record is called the child. (The record in that field is Parent record.)

Step 2: Create Validation rule parent opportunity record should be Contract Sent.

Scenerio 14 :- Create a validation rule to test that the applicant is student.

Steps

Step 1: Create Isstudent field on admission object.

Step 2: Create validation rule for testing Student record id is not null and student isstudent is checked.

Step 3: Test the validation rule.

Scenerio 16 :- Create a validation rule to check that if opportunity goes into closed won stage we can not edit any field on opportunity except stage.

Step 1: Use opportunity object available in your org.

Step 2: Create a validation rule on opportunity object to check if stage closed won. Step 3: If so we can not edit any field on the opportunity object.

Scenerio 17 :- Create a validation rule to check that if opportunity goes into closed won stage we can not edit any field on opportunity except stage also for the stage we can select only Negotiation stage.

Step 1: Use opportunity object available in your org.

Step 2: Create a validation rule on the opportunity object to check if stage closed won.

Step 3: Using AND and OR logical operator’s implement the validation rule to test above condition.

Conclusion

Implementing robust validation rules in Salesforce is not merely about enforcing restrictions; it’s about strategically guiding user actions to align with organizational goals and regulatory requirements. By setting up these rules, businesses can significantly enhance their operational efficiency, ensure data accuracy, and maintain consistency across their workflows. This proactive approach not only mitigates risks but also empowers users by reducing errors and improving the quality of data entered into the system.

Through the scenarios discussed, it becomes evident that validation rules are a critical component in the toolkit of any Salesforce administrator or developer aiming to refine business processes. They serve as the first line of defense against common data entry errors, helping to safeguard the integrity of business operations. As organizations continue to evolve and face new challenges, the flexibility to implement such custom validations in Salesforce will remain a key factor in staying ahead in the competitive market landscape.