You need to sign in to do that
Don't have an account?
XIO
Need Help Duplicate Record Trigger
Hello,
I need the trigger below to only find the duplicate record if the Status__c is 'Active' on both records. Status__c is a picklist field. Any assistance is greatly appreciated!
I need the trigger below to only find the duplicate record if the Status__c is 'Active' on both records. Status__c is a picklist field. Any assistance is greatly appreciated!
trigger DuplicateExecutiveContact on Committee_Board_Member__c (before insert. before update) { for(Committee_Board_Member__c c:Trigger.new) { List<Committee_Board_Member__c> comm=[select ID from Committee_Board_Member__c where Account__c=:c.Account__c and Committee_Board__c=:c.Committee_Board__c and Service_Discipline__c=:c.Service_Discipline__c and Status__c=:c.Status__c]; if(comm.size()>0) { c.adderror('Duplicate Record'); } } }
All Answers
I don't have the Committe Board Member Object in my Org to test.
trigger DuplicateExecutiveContact on Committee_Board_Member__c (before insert. before update) {
for(Committee_Board_Member__c c:Trigger.new)
{
List<Committee_Board_Member__c> matchingCommittemembers=[select ID from Committee_Board_Member__c where Account__c=:c.Account__c and Committee_Board__c=:c.Committee_Board__c and Service_Discipline__c=:c.Service_Discipline__c and Status__c=:c.Status__c];
if(!matchingCommittemembers.isEmpty())
{
for (Committee_Board_Member__c c1 : matchingCommittemembers)
{
if(c1.Status__c == c.Status__c)
{
c.adderror('Duplicate Record');
}
}
}
}
}
Thanks,
Naren
if((c1.Status__c == c.Status__c ) && (c1.Status__c=='Active'))
{
c.adderror('Duplicate Record');
}
Thanks,
Naren