Let’s be honest—most of us have been using Windows since we were kids. It’s the backbone of the corporate world and feels like the default choice for every computer user. For years, I thought it was the only real option. But what if I told you there isn't just an "alternative" out there, but a genuine upgrade? When people talk about switching to Linux , it can feel overwhelming because there are so many versions. However, I want to talk specifically about Ubuntu .
Here is the Sample code to prevent update and insert records between from date and end date in salesforce. This trigger have two events:-
before insert and before update
trigger Duplicatecheck on <Obejct> (before insert,before update) {
set<object > ListOfrecords= new set<object >([SELECT id,Valid_Form__c,Valid_To__c FROM <object>]);
for(<object> obj1 : ListOfrecords) {
for(<object> obj2: Trigger.new) {
if(obj2.VS_State__c== obj1.VS_State__c && obj2.vs_Tax_Type__c == obj1 .vs_Tax_Type__c){
if((obj2.Valid_To__c >= obj1.Valid_Form__c&& obj2.Valid_To__c <= obj1 .Valid_To__c ) ||
(obj2.Valid_Form__c>= obj1.Valid_Form__c&& obj2.Valid_To__c <= obj1 .Valid_To__c ) ||
(obj2.Valid_Form__c>= obj1.Valid_Form__c&& obj2.Valid_Form__c<= obj1 .Valid_To__c ) ||
(obj2.Valid_Form__c< obj1.Valid_To__c && obj2.Valid_To__c > obj1 .Valid_To__c )){
obj2.addError('record already exist between these dates.');
}
}
}
}
}Output:-
| Trigger to prevent insert or update duplicate records. |