Results 1 to 3 of 3

Thread: Enforcing email_address to be unique

  1. #1
    datasponge is offline Sugar Community Member
    Join Date
    Mar 2008
    Location
    San Jose, CA, USA
    Posts
    553

    Default Enforcing email_address to be unique

    Is there a file I can edit to force the email_address (actually email_address_caps) to be enforced by the database as unique?

    When someone opts out, I want to make sure there is not a second identical email anywhere in sugar that would also need to be marked. The underlying email_addresses table (by default) has these fields as keys but not unique. In my experience, changes to the underlying tables get restored to settings defined in the php pages when you repair Sugar, so I need to figure out what php file controls this so the change can be retained.

    From my (minimal) testing Sugar does a good job matching an email added through the interface to not create a duplicate, but I don't know how import behaves and I'm also importing records directly to MySQL in some cases, so I really want the security of the database enforcing uniqueness.

    This is important as in the US you can be sued for sending a bulk email to someone who has opted out.

    Also, because of the importance of this, I'd like to be able to record the email to a log including the date someone opted out. There is currently no way to audit email address changes in 5.0b, so I can't even save the date opt_out was selected. What is a good creative way to implement this without auditing? For example how can I add an html link to an external tool that presents it own screens to collect data and writes to a log table all the key info about an opt_out?

    Since Email Addresses isn't really a visible module I haven't really figured out how to work with it yet. Any advice is appreciated on this.

    Thanks

    Phil

  2. #2
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: Enforcing email_address to be unique

    Hi, Phil

    Just create an extended vardefs for the EmailAddresses with this content:

    PHP Code:
    $dictionary['email_addresses']['indices'][] = array(
        
    'name'            => 'email_addressesuniq',
        
    'type'            => 'unique',
        
    'fields'        => array('email_address')
    ); 
    After that quick repair and rebuild

    Cheers
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  3. #3
    Denzel is offline Sugar Community Member
    Join Date
    Jan 2008
    Posts
    12

    Default Re: Enforcing email_address to be unique

    Hi,

    i have the same problem. Added a new field to Contact. Added the uinique-index. Now the problem is: When i add a value to a Contact that i added to an other Contact, i get a mysql-error. The field is not checked by Sugar before the Contact gets saved How do i get this unique-field checked before Sugar tries to save the Contact?

    Greetings, Dennis

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Integrating a unique field with Sugar
    By tomkerswill in forum Help
    Replies: 7
    Last Post: 2012-01-25, 03:44 AM
  2. How to make a custom field unique
    By sawan in forum Developer Help
    Replies: 2
    Last Post: 2008-03-01, 12:14 PM
  3. How do I make a custom field unique?
    By ztolley in forum Developer Help
    Replies: 4
    Last Post: 2008-02-08, 05:16 PM
  4. Unique Account ID in reports
    By Ryandbair in forum Help
    Replies: 1
    Last Post: 2007-09-07, 01:07 AM
  5. Unique fields
    By aheuermann in forum Help
    Replies: 1
    Last Post: 2006-08-14, 07:13 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •