Account field and integration__c fields combination of record is have already in case object don't allows duplication if sftype__C checkbox is true otherwise allows if sftype__c is false allows for duplication.
This is my trigger but this is also allows duplicates please check it once
trigger AvoidDuplicateInsertions on Case(before insert,before update){
Set<string> accountname= new Set<string>();
Set<string> integrationto= new Set<string>();
for(Case cas: Trigger.new){
accountname.add(cas.Account.Name);
integrationto.add(cas.IntegrationTo__c);
}
List<Case> duplicatecaseList = [Select id,Case.Account.Name,IntegrationTo__c,SFType__c From Case where Case.Account.Name= :accountname AND IntegrationTo__c =:integrationto];
Set<string > duplicatecaseIds = new Set<string >();
for(Case dup: duplicatecaseList ){
duplicatecaseIds .add(dup.Account.Name);
duplicatecaseIds .add(dup.IntegrationTo__c);
}
for(Case s : Trigger.new){
if(s.Account.Name!=null && s.IntegrationTo__c!=null){
if(duplicatecaseIds.contains(s.Account.Name) && duplicatecaseIds.contains(s.IntegrationTo__c)){
if(s.SFType__c = true){
s.addError('Record already exist with same Service');
}
}
}
}
}
but this allows duplication please anyone check it once
Thanks In advance