-
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 Freeze and Deactivate User Accounts in Salesforce
Introduction Here we are going to learn about how to freeze the user and deactivate the user. If your employee left your company then you…
Salesforce Data Cloud: Unlocking the Power of Real-Time Customer Data for Smarter Sales
In today’s fast-paced digital landscape, businesses need real-time, actionable customer insights to stay connected and relevant to their customers. With Salesforce Data Cloud, TechForce Services…
A Guide to Partnership Management Essentials
Only a few businesses have realized that partnership is imperative to be a step above the others in a competitive market. But it's not as…
Popular Salesforce Videos
Salesforce Training Videos For Beginners - 1 | Salesforce Administrator Training
This Salesforce Training Video will help you understand which is the easy and best tool for CRM, Branding, tabs and homepage optimization. This is an…
What are Collections in Apex? | Salesforce Development Course
Shrey explained different types of Collections in Apex in this video. Watch the video now and learn, let us know in the comments if you…
Integer Datatype | Primitive Datatypes in Apex | Salesforce Development Tutorials
Shrey covered the following questions in this video: What are the different types of Datatype? What are Primitive Datatypes? What is the Long datatype? What…