-
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
Custom Notification With Process Builder in Salesforce
Custom Notification is a modified notification where the administrator can add beneficiaries, subjects, and substances. Administrators can be sent a custom notification when any significant…
Create Multiple Records of Salesforce Objects from a Single Page
Presently we can create records by click on tabs of their related objects but through the below-given piece of code, we can create records of…
Creating a Salesforce Strategy in 2021
As 2021 nears its end it’s not pessimistic anymore to imagine that the pandemic will be here for a little longer. Unfortunately, that also means…
Popular Salesforce Videos
PASS Salesforce Certified Administrator Exam on the FIRST Attempt
Want to pass the Salesforce Certified Administrator Exam on the FIRST Attempt? Then this video is for you. Here are the steps: STEP 1 :…
Introduction to Programming | Live Salesforce Development
Learn Salesforce development from start to finish for free. Want to take your Salesforce Knowledge to the next level? Want to learn advanced Salesforce admin,…
How Cross Channel Marketing Can Drive More Engagement ? | Salesforce Marketing Cloud
Cross-channel marketing is a customer-focused digital marketing technique used by marketers globally to provide an integrated experience across all paid, owned, earned media, and digital…