You need to sign in to do that
Don't have an account?
Harshal Katole 7
omparing two multiselectpicklist value
object = contact
multiselect picklist 1 = abc__c => values : 1,2,3,4,5,6,7
multiselect picklist 2 = xyz__c => values : 1,2,3,4,5,6,7
scenario : check both field value not same while creating a record. if its same then thrown error.
i want to use CONTAINS() function insted of ContainsAll() here,.how can i achieved ??
public class checkdupcontact2{
public static void invoke(list<contact> cc){
for(contact a : cc){
if( a.abc__c != null && a.xyz__c != null ){
list<string> VarList1 =a.abc__c.split(';');
list<string> VarList2 =a.xyz__c.split(';');
set<string> VarSetAdd1 = new set<string>();
VarSetAdd1.addAll(VarList1);
set<string> VarSetAdd2 = new set<string>();
VarSetAdd2.addAll(VarList2);
if(VarList1.contains(VarList2)){
a.addError('error');
}
}
}
}
}
multiselect picklist 1 = abc__c => values : 1,2,3,4,5,6,7
multiselect picklist 2 = xyz__c => values : 1,2,3,4,5,6,7
scenario : check both field value not same while creating a record. if its same then thrown error.
i want to use CONTAINS() function insted of ContainsAll() here,.how can i achieved ??
public class checkdupcontact2{
public static void invoke(list<contact> cc){
for(contact a : cc){
if( a.abc__c != null && a.xyz__c != null ){
list<string> VarList1 =a.abc__c.split(';');
list<string> VarList2 =a.xyz__c.split(';');
set<string> VarSetAdd1 = new set<string>();
VarSetAdd1.addAll(VarList1);
set<string> VarSetAdd2 = new set<string>();
VarSetAdd2.addAll(VarList2);
if(VarList1.contains(VarList2)){
a.addError('error');
}
}
}
}
}
Try Below Code Please Mark It As Best Answer If It Helps
Thank You!
2.got "checdupContacttri: execution of BeforeUpdate caused by: System.ListException: List index out of bounds: 3 Class.checkdupcontact2.invoke: line 17, column 1 Trigger.checdupContacttri: line 6, column 1" error while inserting abc__c = 1,2,5,7 and xyz__c = 2,3,5
public class checkdupcontact2{
public static void invoke(list<contact> cc){
for(contact a : cc){
if( a.abc__c != null && a.xyz__c != null ){
list<string> VarList1 =a.abc__c.split(';');
system.debug(VarList1);
list<string> VarList2 =a.xyz__c.split(';');
system.debug(VarList2);
/*set<string> VarSetAdd1 = new set<string>();
VarSetAdd1.addAll(VarList1);
set<string> VarSetAdd2 = new set<string>();
VarSetAdd2.addAll(VarList2);*/
for(Integer i=0;i < VarList1.size();i++){
if(VarList1[i].Contains(VarList2[i])){
a.addError('error');
}
}
}
}
}
}