Results 1 to 2 of 2
Like Tree1Likes
  • 1 Post By andopes

Thread: vardefs relationships

  1. #1
    mano.f is offline Junior Member
    Join Date
    Sep 2011
    Location
    Honolulu, HI
    Posts
    3

    Default vardefs relationships

    Hello everyone,

    I just started working with sugar crm and noticed something funny with the relationships I created in studio. When I look in the filesystem at the file vardefs.ext.php, my relationship names get changed into a mess, here is an example


    $dictionary["Dev_LinkPerson"]["fields"]["dev_partic5013cipant1_ida"] = array (
    'name' => 'dev_partic5013cipant1_ida',
    'type' => 'link',
    'relationship' => 'dev_participant1_dev_linkperson',
    'source' => 'non-db',
    'reportable' => false,
    'side' => 'right',
    'vname' => 'LBL_DEV_PARTICIPANT1_DEV_LINKPERSON_FROM_DEV_LINK PERSON_TITLE',
    );

    When I try to reference the relationship I created 'dev_participant1_dev_linkperson', nothing happens and I have to use the relationship 'dev_partic5013cipant1_ida' instead.
    Why is this?
    I'm using 6.1 CE

  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: vardefs relationships

    Relationships created by Studio are built in an upgrade safe way, the way its foreign keys are stored in an extra table instead of core table.

    So for your scenario, it seems you created an One to Many relationship between Participant and Person, so SugarCRM creates an extended vardefs for Person with the fields:

    <relationship_field>_id: pseudo field to store related id
    <relationship_field>_name: pseudo field to store related name
    <relationship_field>: pseudo field to fetch a list of related records (dev_participant1_dev_linkperson)


    And an extended vardefs for Participant with the field:
    <relationship_field>: pseudo field to fetch a list of related records

    Whenever you create a record from Person you can specify the Participant in 2 ways:
    PHP Code:
    $person->dev_partic5013cipant1_ida 'some value'
    This will make SugarCRM saves the Participant in the relationship table as soon as you save the $person.

    PHP Code:
    $person->save();
    $person->load_relationship('dev_participant1_dev_linkperson');
    $person->dev_participant1_dev_linkperson->add('some value'); 
    This will automatically save the Participant id in relationship table.

    Cheers
    mano.f likes this.
    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.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Extended vardefs vardefs.ext.php vanishes after deploy
    By amrutha in forum Developer Help
    Replies: 3
    Last Post: 2011-06-10, 12:13 PM
  2. Custom vardefs do not overwrite original vardefs
    By TheEyes in forum Developer Help
    Replies: 5
    Last Post: 2009-07-22, 09:56 AM
  3. Creating open relationships with any table in vardefs
    By rudibr30 in forum Developer Help
    Replies: 1
    Last Post: 2008-09-24, 07:23 PM
  4. Vardefs and relationships question
    By marketadvantage in forum Developer Help
    Replies: 0
    Last Post: 2008-03-26, 07:39 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
  •