Page 1 of 4 1234 LastLast
Results 1 to 10 of 33

Thread: how to check for the duplicates ?

  1. #1
    bandsb is offline Sugar Community Member
    Join Date
    Feb 2008
    Posts
    25

    Default how to check for the duplicates ?

    Hi

    I builded a new module using module builder, i created a default field called sheet_name, i dont want allow duplicate values to sheet_name, When user saving the data, it should check the existing sheet_names in db, and if any thing exist with the same name, i want to show the error message saying that already another sheet exists with this name.. any help would be appreciated

    Thanks
    bands

  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: how to check for the duplicates ?

    Hi bands

    You need to implement an ajax based javascript on button SAVE to query database against existing duplicates.
    How are your skills regarding php, ajax, javascript and SugarCRM development?

    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
    bands is offline Sugar Community Member
    Join Date
    Aug 2006
    Posts
    41

    Default Re: how to check for the duplicates ?

    Thanks Andopes

    I have experience with php , and sugarcrm

    Can u guide me the step by step process to accomplish my requirement. ( in which files i should write the hack for this)

    so that i can code as per your guide lines

    I really appreciate your help.

    Thanks
    bands

  4. #4
    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: how to check for the duplicates ?

    Hi Bands

    Create a view.edit.php for your custom modules and implement the function process like that:

    PHP Code:
        function process() {
            
    parent::process();

            global 
    $db;
            
            
    $fields = array();
            
    $query "SELECT DISTINCT sheet_name FROM <table_name> WHERE deleted = 0";
            
    $result $db->query($querytrue"Error retrieving sheet_name values: ");

            while(
    $row $db->fetchByAssoc($result)) {
                
    $fields[] = $row['sheet_name'];
            }

            
    $json_fields json_encode($fields);
            echo 
    "<script>addToValidateIsInArray('EditView', 'sheet_name', 'in_array', 'true', 'Duplicated value on database', '{$json_fields}', '==')</script>";
        } 
    Obviously you have to consider modify something to fits your needs.

    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.

  5. #5
    bands is offline Sugar Community Member
    Join Date
    Aug 2006
    Posts
    41

    Default Re: how to check for the duplicates ?

    Andopes Thanks for your help .

    Created a file view.edit.php in modules/Sheets folder,

    added the class called SheetsEditview extends EditView

    in that class called the function process.

    when i check for the validation, even this page is not getting executed.

    Could you please correct me.

    I really appreciate your help Andopes.

    Thanks
    bands

  6. #6
    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: how to check for the duplicates ?

    Hi Bands

    This night I'll deliver the new release of DevToolKit which implements in an easy to use way such feature.

    Kind regards
    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.

  7. #7
    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: how to check for the duplicates ?

    I just released the DevToolKit 0.5 which implements the Duplicate Fields Validation.

    Enjoy this and let me know if you face any issue.

    Regards
    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.

  8. #8
    meryblue82 is offline Junior Member
    Join Date
    May 2009
    Posts
    4

    Default Re: how to check for the duplicates ?

    Hello:
    I use a translator to write this post ... sorry for my slightly English

    My doubt is the following one, install the DevToolKit 0.5, create a module that is called " Alumnos ", I have did everything that thing about the user's guide, I create the view.edit.php, view.detail.php and the view.list.php, my need was use checkForDuplicates for a field inside the module, I did it as he was saying in the user's guide inside the matadata create a check_duplicate_fields.php, but it does not work, it does not verify that the fact does not repeat itself...

    This are my codes:

    Edit
    PHP Code:
    <?php
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
    require_once(
    'include/MVC/View/views/view.edit.php');
    class 
    AlumnosViewEdit extends ViewEdit {
    private 
    $manager;
    function 
    init($bean null$view_object_map = array()) {
    parent::init($bean$view_object_map);
    require_once(
    'custom/include/utils/DevToolKitManager.php');
    $this->manager = new DevToolKitManager($this);
    }function 
    display() {
    $this->manager->display();
    $this->ev->process();
    echo 
    $this->ev->display();
    }
    function 
    process() {
    parent::process();
    $this->manager->process();
    }
    }
    ?>
    Detail
    PHP Code:
    <?php
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
    require_once(
    'include/MVC/View/views/view.detail.php');
    class 
    AlumnosViewDetail extends ViewDetail {
    private 
    $manager;
        function 
    init($bean null$view_object_map = array()) {
    parent::init($bean$view_object_map);
    require_once(
    'custom/include/utils/DevToolKitManager.php');
    $this->manager = new DevToolKitManager($this);    }
    function 
    process() {
    $this->manager->process();
    parent::process();
    }
    }
    ?>
    List
    PHP Code:
    <?php
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
    require_once(
    'include/MVC/View/views/view.list.php');
    class 
    AlumnosViewList extends ViewList {
    private 
    $manager;
        function 
    init($bean null$view_object_map = array()) {
    parent::init($bean$view_object_map);
    require_once(
    'custom/include/utils/DevToolKitManager.php');
    $this->manager = new DevToolKitManager($this);
        }
    function 
    process() {
    $this->manager->process();
    parent::process();}
    }
    ?>
    And check
    PHP Code:
    <?php
    $check_duplicate_fields 
    = array(
    'run_alumno'
    );
    ?>
    run_alumno is a unique number for every student ....

    Can you Help Me?

  9. #9
    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: how to check for the duplicates ?

    Hi Mary Blue

    Thank you for trying this.

    Figure it out some details:
    Make sure the module name has no a prefix, like blue_Alumnos;
    Make sure you had specified the correct name for the metadata file: check_duplicate_fields.php

    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.

  10. #10
    meryblue82 is offline Junior Member
    Join Date
    May 2009
    Posts
    4

    Default Re: how to check for the duplicates ?

    Hello andropes:

    Thanks for your answer, the truth is that my module is called re01_Alumnos therefore modify the php files view.edit, view.detail and view.list in the line of the file where it says "class re01_AlumnosViewDetail extends ViewDetail", on the other hand, I realized that the files should go into the folder CUSTOM and not in MODULES, I made all these modification, but still does not work check_duplicate_fields.php ...

    Any idea?

Page 1 of 4 1234 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. HOW TO?:check for duplicates with get_entry_list module
    By WelkerM in forum Developer Help
    Replies: 6
    Last Post: 2009-01-13, 10:56 AM
  2. Replies: 0
    Last Post: 2008-10-17, 09:53 AM
  3. Replies: 0
    Last Post: 2008-08-31, 07:03 AM
  4. Getting rid of duplicates
    By EC in forum Help
    Replies: 2
    Last Post: 2006-02-16, 03:19 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
  •