title: Display Alert box through the trigger - salesforce
body: <p>Is it possible to display an alert message (not error message) through a trigger? I have written a trigger that checks for duplicate accounts in the system. The trigger at the moment gives an error message to the user telling that there is a duplicate account. But, if the user changes the value of a field "Is record near to duplicate?" to YES, the trigger allows the user to save the record.</p>
  
  <p>But, I want to display the error message in an alert pop up box like "Account with this Name exists,are you sure you want to continue" and then user clicks Yes and the record gets created. Any thoughts on how I can do this. My code is below:</p>
  
  <pre><code>for(Account account: System.Trigger.New)  
  {  
   if(accountMap.containsKey(account.Physical_Street__c)==accountMap2.containsKey(account.Phone))
   if(accountMap.containsKey(account.Physical_Street__c)==accountMap3.containsKey(account.Name))  
   if(account.Is_record_near_to_duplicate__c.equals('No'))  
    {  
     account.addError('Account with this Name,Street and Phone Number already      exists. If you still wish to create the agency change the value of field "Is Record Near To Duplicate" to YES');  
    }  
  }
  </code></pre>