You need to sign in to do that
Don't have an account?
Chirag Mehta
Duplicate Contact Check - Before Insert Trigger
For checking of contact duplicates before inserting them is fine ,its works fine as i had written a before insert trigger for the same.
But i need something extra in the before insert trigger ........
1. To display the Account Name of already existing Contact Name in SFDC (Done--Achieved)
2. A message or alert with yes or no button saying tht 'would u like to proceed with creating of this contact ,though its duplicate exists' and if he clicks yes then the contact shld be created..overriding the before insert trigger written by me ... (Help Needed on this)
But i need something extra in the before insert trigger ........
1. To display the Account Name of already existing Contact Name in SFDC (Done--Achieved)
2. A message or alert with yes or no button saying tht 'would u like to proceed with creating of this contact ,though its duplicate exists' and if he clicks yes then the contact shld be created..overriding the before insert trigger written by me ... (Help Needed on this)
Message Edited by Chirag Mehta on 05-07-2007 01:46 AM
You can achive this, by stating the user a message that if you still want this record to be inserted then select one Custom created Field as true ...then on the Save Button your trigger will not be called based on the status of this ...check box.....
If you find anyother way..then post it...!!
But lets try to make something automate so that user needs to perform only one action instead of two
1. select check box
2. save
i like this. it is important to me too. i wonder how do i do this.
what code should i write and where?
thanks.
so kind of you Chirag. Let me try it!
thank you very much.
Hi Chirag,
Is this trigger valid for Contact checking or only for leads?. I require a trigger to prevent duplicate contacts and account entry. Can you help me.
Thanks
Compile Error: Initial term of field expression must be an SObject: ARRAY:SOBJECT:Lead
I just copied and pasted what was posted, although I had to add 'bulk' after Lead on the first line. Can anyone help? Thanks.
Thanks.
Abt Second prblm ,i too cant help u in that ...
if (Trigger.new.Email != NULL) {
Lead[] leads = [ select id from Lead WHERE email = :Trigger.new.Email];
if (leads.size() > 0) {
Trigger.new.Email.addError('Email already exists');
}
}
}
But if we dont add bulk keyword ,then we get the error ...
Error: Compile Error: Single row trigger not allowed, use the bulk keyword at line 1 column 1
I too dont know why salesforce stop support of single row trigger which were working fine few days back
2. If u use bulk keyword , no longer the new is single variable ..
IT becomes a array variable ...though it is single column array ...
Something like new [i] ..so u need to use Trigger.new[0].Email
So now the code changes to
trigger leadEmailCheck on Lead bulk (before insert) {
if (Trigger.new[0].Email != NULL) {
Lead[] leads = [ select id from Lead WHERE email = :Trigger.new[0].Email];
if (leads.size() > 0) {
Trigger.new[0].Email.addError('Email already exists');
}
}
}
Hello Jirag,
It works! Thanks a lot.
I wonder how i can do this in Unlimited Edition. It has no triggers :(
On Unlimited Edition or Sandbox ...still they arent supported...
Hope to see Saleforce provides the same @ earliest. I think thy re testing the triggers stuff and once it is robust and bug free it will be available on all editions of Salesforce
Error: Compile Error: Initial term of field expression must be an SObject: ARRAY:SOBJECT:Lead at line 9 column 73
this is using the *exact* cut and paste sample trigger from the ApexWiki at:
http://wiki.apexdevnet.com/index.php/Apex_Code:_The_World%E2%80%99s_First_On-Demand_Programming_Language#Apex_Code_Example
when I try to add it as a New Trigger in the Lead "buttons and links".
http://community.salesforce.com/sforce/board/message?board.id=apex&message.id=442#M442
It is only when I go to the forum index that I can see the 1 2 3 to jump to the later threads.
PG
clcik on show printer friendly and u can read all the post in one page ...
instead of directly using the select statement its better you use a FOR statement
for(Account acc : [select id, name from Account])
{
}
Wonder full logic sir/mam