-
How to compare Trigger.new values with Trigger.old values
I have a junction object 'Related Products' which has master detail relationship with 'Contact' and have a lookup relationship with 'Product'. And I have added a related list of 'Related Products' in Contact detail page where user can create new Related Product from the Contact and can add multiple Products to it.
Now my requirment is "if any user selects a product which is already selected to that contact should through error".
For example, I have contact called "Test Contact111", In it I have created one Related Product "RP-0001" and selected a Product called "Prod111", It will get to save and will show in the Contact's detail page under 'Related Products' section.
Again from the same Contact I will create another Related Product "RP-0002" and again will select the Same Product "Prod111", now the trigger need to throw an error states "Prod111 is already selected"
Log In to reply.
Popular Salesforce Blogs
How To Resolve When Salesforce Error Apex Heap Size Too Large
Salesforce upholds an Apex Heap Size Limit of 6MB for synchronous execution and 12MB for Asynchronous execution. The "Pinnacle stack size excessively huge" mistake happens…
10 Commandments Of Becoming An Excellent Salesforce Administrator
Have you heard the entire hassle-bustle about Salesforce these days? Are you tantalized by the great Salary structures of various profiles in Salesforce? Well, you…
What is Lightning Web Runtime(LWR) in Salesforce?
Introduced in Spring 21, Experience Cloud's Build Your Own (LWR) Templates are lightweight templates that use the Experience Cloud's Lightning Web Runtime (LWR) platform. With…
Popular Salesforce Videos
How to Deliver Great Customer Service With a Small Team [Salesforce Webinar]
Overwhelmed by a backlog of customer service requests? And worried your team is too small to handle all the requests? Then, this video is for…
Skill Based Routing with Apex/Flows in Salesforce
This video is the sequel to the omnichannel Salesforce tutorial (LINK) In this video, we will cover: 1. What is Skill-based routing 2. Why is…
Smart Merchandising with Salesforce Einstein AI
Smart Merchandising is a holistic tool that magically combines rich insights from site-wide search, navigation, purchases, and the customer’s current session with strategic business goals.…