Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Update field form another field module

  1. #1
    titobustillo is offline Sugar Community Member
    Join Date
    Jan 2010
    Posts
    56

    Default Update field form another field module

    I know this issue can be resolved with a logic hook, but I have terrible programming skills.
    I have a custom module, and its relationship with Leads is Many to One (to one lead). I have a custom field in Leads, and I want to show its value in a custom field in custom module (and this field in custom module can be searched in advanced search).
    Surely is a simple logic hook, and I have readed (without undersand because my low programming skills) the wiki and several post.
    Sugar Gurús, help, please.
    Last edited by titobustillo; 2011-04-05 at 02:57 PM.

  2. #2
    Topas_C is offline Senior Member
    Join Date
    Aug 2010
    Location
    Russia,Moscow
    Posts
    38

    Default Re: Update field form another field module

    Good evening,
    for exampla, but with russian comments.
    PHP Code:
    function Get_Date (SugarBean $bean,$event,$argument)  
    {  
      
    $r_contact $bean->get_related_list(New Contact(),"contacts_o1111_opportunites_new");  
         if ( 
    count($related_contacts['list'])==)  
          {  
    // а зачем забыли оквадратноскобочить справа аттрибут 'list'?  
            
    $contact_bean $r_contact['list'][0];  
          
    // Получили связанный контакт  

    // А теперь получим custom_fields этого связанного по рукам и ногам контакта  
       
    $contact_bean->custom_fields->retrieve();  

          
    $contact_id $contact_bean->id;   // Получаем id записи  

    // Теперь то, что дальше вроде как должно работать  
           
    $contact_temp $contact_bean->temp_c// Пытаемся получить значение поля temp_c  
    // Не пытайся! Просто получи это значение!!!  

          
    $GLOBALS['log']->debug('ID = ' $contact_id ' ,TEMP_C = ' $contact_temp );  
                 
                if (
    $contact_temp ==2)   
                     {  
                       
    $contact_bean->temp_c 1;  
                       
    $contact_bean->custom_fields->save();    // В случае если использовать, обнуляются 
    //некоторые поля в contacts_cstm 

                      
    }  
              }  

    If You don't undestand this code, I could tell you more about it.
    Last edited by Topas_C; 2011-04-05 at 07:43 PM.
    SugarCRM 6.1.2
    Russia,Moscow.

  3. #3
    titobustillo is offline Sugar Community Member
    Join Date
    Jan 2010
    Posts
    56

    Default Re: Update field form another field module

    Thanks Topas_C.
    I have checked your example. Its related to Contacts module, isnt it? All I must do is change Contacts to my custom module?
    I dont understand what is "contacts_o1111_opportunites_new". Thanks in advance for your help.

  4. #4
    Topas_C is offline Senior Member
    Join Date
    Aug 2010
    Location
    Russia,Moscow
    Posts
    38

    Default Re: Update field form another field module

    Yes, it relate from my Module to Contact module.
    "contacts_o1111_opportunites_new" - This is Relationship name between my Module and Contact.
    If you don't know relationship name, you could see it in Studio.
    SugarCRM 6.1.2
    Russia,Moscow.

  5. #5
    titobustillo is offline Sugar Community Member
    Join Date
    Jan 2010
    Posts
    56

    Default Re: Update field form another field module

    And where is located the reference to custom field than I want to autopopulate? thanks.

  6. #6
    Topas_C is offline Senior Member
    Join Date
    Aug 2010
    Location
    Russia,Moscow
    Posts
    38

    Default Re: Update field form another field module

    Here you get all the fields
    $contact_bean->custom_fields->retrieve();
    After that you can get some fields, in example "id".

    All your fields you could see in Studio.
    SugarCRM 6.1.2
    Russia,Moscow.

  7. #7
    titobustillo is offline Sugar Community Member
    Join Date
    Jan 2010
    Posts
    56

    Default Re: Update field form another field module

    Thanks for your efforts, but I'm unable to do it work...how I wrote, my programming skills is near to 0 (maybe 1 ). I cant use your example. I will continue looking for.
    Thanks anyway.

  8. #8
    Kupido is offline Sugar Community Member
    Join Date
    Apr 2011
    Posts
    60

    Default Re: Update field form another field module

    Hello

    another question, where can i insert the code? in which file?
    and is it also possible with one module
    i have some tabs in contact for example: contact|more information|data1|data2
    I have some fields in data1 and a part from these fields in data2.

    Is it possible then i save that the fields from data1 update the fields in data2?

  9. #9
    Topas_C is offline Senior Member
    Join Date
    Aug 2010
    Location
    Russia,Moscow
    Posts
    38

    Default Re: Update field form another field module

    Kupido Good Evening,
    Have you read this part about logic hook before?

    http://developers.sugarcrm.com/docs/...r.html#9000530
    SugarCRM 6.1.2
    Russia,Moscow.

  10. #10
    Kupido is offline Sugar Community Member
    Join Date
    Apr 2011
    Posts
    60

    Default Re: Update field form another field module

    hello thanks for the answer
    i found it yesterday also and read it.

    thanks, and sorry

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. Update contact field from calls module
    By japtone in forum Developer Help
    Replies: 1
    Last Post: 2011-03-15, 06:53 PM
  2. update a field when a record is removed form subpanel
    By anjireddy987 in forum Developer Help
    Replies: 2
    Last Post: 2010-05-03, 10:52 AM
  3. How to add custom field data from web form to lead module
    By babish006 in forum Developer Help
    Replies: 1
    Last Post: 2010-04-16, 04:51 AM
  4. Using workflows to update a module field with value from linked module
    By InHand Electronics in forum Developer Help
    Replies: 0
    Last Post: 2009-11-20, 04:58 PM
  5. Replies: 0
    Last Post: 2007-01-16, 05:27 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
  •