Results 1 to 4 of 4

Thread: ¿How to make Unique Fields?

  1. #1
    fernando.g is offline Junior Member
    Join Date
    Oct 2010
    Posts
    4

    Default ¿How to make Unique Fields?

    Hi:

    Im testing Sugar CE 6.0.1 and i need to make a unique field. I know how to make (or add) new fields to a module, but i need a "unique" or "not repeatable" kind of field.
    For example, if this field is the "ID Number" of a person, i need that Sugar doesnt let anybody have the same "ID Number" value in that field.

    My server is using MYSQL 5.0.91-community and PHP 5.2.14.

    Any help will be appreciate.

    Thanks!.
    Last edited by fernando.g; 2010-10-07 at 03:37 AM.

  2. #2
    davidboris is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    1,113

    Default Re: ¿How to make Unique Fields?

    Hello,

    You can create an auto-increment by extending vardefs. It is not available in studio.
    Thumbs up.

    Skype ID - david__boris

    SugarForge Projects:

    WYSIWYG now in studio!(Version 1.1 is out now!)

    Sugar Feeds on your personalized home pages like iGoogle, My Yahoo!, etc.

    Fab Tools! > Dashlet Not Followed Opportunities for past six Months

  3. #3
    fernando.g is offline Junior Member
    Join Date
    Oct 2010
    Posts
    4

    Default Re: ¿How to make Unique Fields?

    Quote Originally Posted by davidboris View Post
    Hello,

    You can create an auto-increment by extending vardefs. It is not available in studio.
    thanks for your response, but thats not quite what i was looking for. auto-increment will make me a unique field, but i dont want an auto-generated value, i need a custom unique value. I mean, the user can put any value (a number or a name) and that Sugar could understand that this value must be unique.

    I was thinking that changing or adding a little of code (php and sql) i could make a query that in the action of pressing "save" in a new Account, this code asked to the database if another Account has the same value in this unique field before saving the new Account.
    ¿Is this possible? and ¿which is the php file that i need to edit to do this?


    thanks so much!.

  4. #4
    davidboris is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    1,113

    Default Re: ¿How to make Unique Fields?

    Hello,

    There are two ways, you can either write a before_save logic hook, which will submit your page and shows an error message before saving the record if the condition does not match. But as it saves the form you will loose the values filled in.

    Another way is AJAX way, you can write a function onBlur event of the field(file to modify custom/modules/<YOUR_MODULE>/metadata/editviewdefs.php) and call a script which will return true or false. If it returns false, remove the data filled in that field.
    Thumbs up.

    Skype ID - david__boris

    SugarForge Projects:

    WYSIWYG now in studio!(Version 1.1 is out now!)

    Sugar Feeds on your personalized home pages like iGoogle, My Yahoo!, etc.

    Fab Tools! > Dashlet Not Followed Opportunities for past six Months

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to make a custom field unique
    By sawan in forum General Discussion
    Replies: 1
    Last Post: 2008-03-03, 11:41 PM
  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 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
  •