Page 1 of 2 12 LastLast
Results 1 to 10 of 14
Like Tree2Likes

Thread: copy the value of a relate field, to other module

  1. #1
    garciasanchezdaniel's Avatar
    garciasanchezdaniel is offline Sugar Community Member
    Join Date
    Aug 2011
    Location
    Spain
    Posts
    403

    Question copy the value of a relate field, to other module

    hello friends, now my sugar is starting to like to me haha
    I have other issue, I will try to explain it at the next image at the best way:

    NOTE:The fields of the second module are of kind related to contacts
    Attached Images Attached Images  

  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: copy the value of a relate field, to other module

    You can implement this code instead, so you can access the related values directaly.

    PHP Code:
    $first_module loadBean('FirstModule');
    $first_module->retrieve('first_module_id');
    $this->field $first_module->related_field
    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
    agcopley is offline Sugar Community Member
    Join Date
    Nov 2007
    Location
    Santiago, Chile
    Posts
    204

    Default Re: copy the value of a relate field, to other module

    Quote Originally Posted by garciasanchezdaniel View Post
    hello friends, now my sugar is starting to like to me haha
    I have other issue, I will try to explain it at the next image at the best way:

    NOTE:The fields of the second module are of kind related to contacts
    Hola Daniel
    Revisa esta entrada Blog
    SugarCRM Developer Blog » Blog Archive » HOWTO: Using a relate field to populate a custom field

    Slds
    Andrew

  4. #4
    agcopley is offline Sugar Community Member
    Join Date
    Nov 2007
    Location
    Santiago, Chile
    Posts
    204

    Default Re: copy the value of a relate field, to other module

    Quote Originally Posted by garciasanchezdaniel View Post
    hello friends, now my sugar is starting to like to me haha
    I have other issue, I will try to explain it at the next image at the best way:

    NOTE:The fields of the second module are of kind related to contacts
    Hola Daniel
    Revisa esta entrada Blog
    SugarCRM Developer Blog » Blog Archive » HOWTO: Using a relate field to populate a custom field

    Slds
    Andrew

  5. #5
    garciasanchezdaniel's Avatar
    garciasanchezdaniel is offline Sugar Community Member
    Join Date
    Aug 2011
    Location
    Spain
    Posts
    403

    Default Re: copy the value of a relate field, to other module

    Quote Originally Posted by andopes View Post
    You can implement this code instead, so you can access the related values directaly.

    PHP Code:
    $first_module loadBean('FirstModule');
    $first_module->retrieve('first_module_id');
    $this->field $first_module->related_field
    Cheers

    I added this code firstly, and then appeared an error message that says that the function retrieve calls non a object.

    PHP Code:
    $contacts loadBean('Contacts');
    $contacts->retrieve($_REQUEST['id_contacto']);
    $this->related_to_contactsr_c $contacts->related_to_contactsr_c
    So, next, I added this other, but nothing happensdoesn't appear any error message but all continues equal

    PHP Code:
    $contacts = new Contact();
    $contacts loadBean('Contacts');
    $contacts->retrieve($_REQUEST['id_contacto']);
    $this->related_to_contactsr_c $contacts->related_to_contactsr_c
    One question: I have realized that, next to create one relate field, in my table_cstm automatic have created two new fields:relatefield_id_c and relatefield_c.
    But, it only inserting records in database in relatefield_id_c, not in relatefield_c. For this, I don't find the value in order to retrieve and save it
    (as I do with the other fields of database, that contain the values that I need)
    Last edited by garciasanchezdaniel; 2011-09-16 at 08:04 AM.

  6. #6
    garciasanchezdaniel's Avatar
    garciasanchezdaniel is offline Sugar Community Member
    Join Date
    Aug 2011
    Location
    Spain
    Posts
    403

    Default Re: copy the value of a relate field, to other module

    Where the value of a related field is saved in database?

  7. #7
    garciasanchezdaniel's Avatar
    garciasanchezdaniel is offline Sugar Community Member
    Join Date
    Aug 2011
    Location
    Spain
    Posts
    403

    Default Re: copy the value of a relate field, to other module

    Now it works, the value of the field of the first module is copied to the field of the second module,

    but when I press the button save, appear: "no matches found for the field"

    how can I solve this issue?
    Last edited by garciasanchezdaniel; 2011-09-16 at 10:41 AM.

  8. #8
    garciasanchezdaniel's Avatar
    garciasanchezdaniel is offline Sugar Community Member
    Join Date
    Aug 2011
    Location
    Spain
    Posts
    403

    Default Re: copy the value of a relate field, to other module

    Solved!! The issue was that id of the relate field wasn't been copied properly...I realized using firebug,
    So, the fix was add to the code:

    PHP Code:
    $this->related_to_contactsr_id_c $contacts->related_to_contactsr_id_c
    In this way, the id of the relate field is copied, and I can save this new record withour introduce manually the relate field, instead is copied of the first module

    Thanks so much

  9. #9
    garciasanchezdaniel's Avatar
    garciasanchezdaniel is offline Sugar Community Member
    Join Date
    Aug 2011
    Location
    Spain
    Posts
    403

    Default Re: copy the value of a relate field, to other module

    Hello again, this question is for andopes:
    is this piece of code secure? ,that is, can fail any times this code? specifically, loadBean()?
    because I realized that, some times, it doesn't charge properly and then it appears a screen like this in the navigator:
    (this happen with some records)
    Attached Images Attached Images  
    Last edited by garciasanchezdaniel; 2011-09-20 at 07:58 AM.

  10. #10
    Angel's Avatar
    Angel is offline Sugar Community Member
    Join Date
    Jul 2005
    Location
    Los Angeles
    Posts
    4,813

    Default Re: copy the value of a relate field, to other module

    La verdad que nunca he usado loadBean() para poder comentar, pero si he hecho algo parecido varias veces, usando algo como esto:

    Code:
    require_once('modules/Contacts/Contact.php');
    $contact = new Contact();
    $contact->retrieve($contact_id);
    $this->related_to_contactsr_c = $contacts->related_to_contactsr_c;
    $contact->save();
    Intentelo asi..
    Regards,

    Angel Magaña
    Co-Author: Implementing SugarCRM 5.x (Packt Publishing -- Sept. 2010)
    Blog: http://cheleguanaco.blogspot.com.
    Twitter: @cheleguanaco.

    ________
    | Projects: |_____________________________________
    |
    | CandyWrapper (.NET Wrapper for SugarCRM SOAP API). Source now available on GitHub!
    | GoldMine to SugarCRM Express Conversion. Latest: 1.0.1.7 (Nov. 3, 2009)
    | CRM SkyDialer (Skype Integration). Latest: 1.0.2 (Feb. 17, 2010)
    | Round Robin Leads Assignment
    | Phone Number Formatter
    | CaseTwit (Twitter Integration)
    ______________________________________________

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. copy the value of a field from one module to another
    By garciasanchezdaniel in forum Developer Help
    Replies: 7
    Last Post: 2011-08-26, 07:12 AM
  2. retireve field relate from other module ??
    By amine_css in forum Developer Tutorials
    Replies: 0
    Last Post: 2011-05-06, 09:44 AM
  3. Replies: 6
    Last Post: 2010-03-05, 12:38 PM
  4. Replies: 2
    Last Post: 2009-07-17, 02:16 AM
  5. Copy relate with Duplicate button
    By JWG in forum Help
    Replies: 2
    Last Post: 2008-10-26, 07:11 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
  •