-
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

Salesforce Consulting Services: What Does a Salesforce Administrator Do?
It is evident from the fact that any given technology can bring laurels to a company. Not only this, but it can also brighten job…

How Hiring a Salesforce Implementation Partner Could Benefit the Healthcare Sector
Digitalization of healthcare is a complex task due to the sector's unique challenges, such as handling various types of data and interdependent roles. Salesforce implementation…

7 Salesforce Predictions To Be Turned Into Reality In 2019
Salesforce has gone through numerous advancements in the past years (Check the timeline of Salesforce here- Infographic | The Timeline: 20 Years of Salesforce). We…
Popular Salesforce Videos
How to Find out Who Deleted a Record in Salesforce
Salesforce administrators can determine who deleted a record by looking at the Recycle Bin or querying for deleted records via API. Watch this video and…
Difference between Profile and Roles in Salesforce
Learn about the difference between Profile and Roles? Watch this video and do let us know if you have any questions or concerns.
How Salesforce is Paving The Way To Greater Digital Transformation
Digital transformation success is often a question of speed & implementation. Companies know how important technology is to their business, but can they evolve and…