Results 1 to 8 of 8

Thread: Reference a record by custom field, not name

  1. #1
    nat8100 is offline Senior Member
    Join Date
    May 2009
    Posts
    27

    Default Reference a record by custom field, not name

    How can I change what a record is referenced by?

    For example, in the contacts database the contact is called by first name/last name, and the accounts module uses the account name field. This is used when displaying the detail view at the top (Accounts: Account name), in the list view(you can click to view on the name) and also in the last viewed. It is also used as the lookup field when you create a relate field in another module.

    I want to reference a record by a custom field, instead of the name. This is for a recruitment module. Many candidates have the same name so I want to assign them each an ID/reference no. and call them by that.

    Hopefully I have explained enough for you to know what I mean.

    Thank you

  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: Reference a record by custom field, not name

    Do you want to implement it into a built in module or into a custom module?

    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
    nat8100 is offline Senior Member
    Join Date
    May 2009
    Posts
    27

    Default Re: Reference a record by custom field, not name

    Quote Originally Posted by andopes View Post
    Do you want to implement it into a built in module or into a custom module?

    Cheers
    Thanks for your quick reply.

    A custom module, based on the person template

  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: Reference a record by custom field, not name

    You should implement the save function into module class to set the name field as the other field which has unique values.
    Also implement the function get_summary_text into module class. This function will return the name of the field which will be displayed into Last Viewed.

    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
    nat8100 is offline Senior Member
    Join Date
    May 2009
    Posts
    27

    Default Re: Reference a record by custom field, not name

    Quote Originally Posted by andopes View Post
    You should implement the save function into module class to set the name field as the other field which has unique values.
    Also implement the function get_summary_text into module class. This function will return the name of the field which will be displayed into Last Viewed.

    Cheers
    Which file is the save function class and get_summary_text currently located?
    Thanks

  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: Reference a record by custom field, not name

    Lets suppose your custom module is the nat_Payments, the module class is the modules/nat_Payments/nat_Payments.php
    So you should implement into this class the two methods I told you before.
    Both methods are defined into data/SugarBean.php

    the methods would like like that:

    PHP Code:
      function save($check_notify false) {
        
    $this->name $this->field_with_unique_value;
        
    parent::save($check_notify);
      }

      function 
    get_summary_text() {
        return 
    $this->field_with_unique_value;
      } 
    Obviously you should replace the field_with_unique_value by the appropriate field name.

    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.

  7. #7
    nat8100 is offline Senior Member
    Join Date
    May 2009
    Posts
    27

    Default Re: Reference a record by custom field, not name

    Ok thank you for the additional info. If it is defined into sugarbean.php do I need to define which module so it doesn't apply to all modules?

  8. #8
    Join Date
    Sep 2011
    Posts
    8

    Default Re: Reference a record by custom field, not name

    Hello, i would like to do the same thing. I made a custom module based on file template. I want to reference a custom field to view/access the records. I'm currently using SugarCRM Version 6.3.0beta6 (Build 6874). thanks.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 0
    Last Post: 2009-01-07, 06:56 PM
  2. how to make a field to order by record
    By kinshibuya in forum Help
    Replies: 1
    Last Post: 2008-08-27, 02:01 PM
  3. record not coming in supanel field
    By abhitosh in forum Developer Help
    Replies: 1
    Last Post: 2008-07-27, 07:20 PM
  4. Logic hooks reference form field values
    By JVWay in forum Developer Help
    Replies: 2
    Last Post: 2008-05-14, 11:00 PM
  5. Custom Module - Name field not linking to record
    By robert.blasingame in forum Help
    Replies: 5
    Last Post: 2008-01-31, 07:30 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
  •