Results 1 to 6 of 6

Thread: record id

  1. #1
    blitz2190 is offline Senior Member
    Join Date
    Jul 2009
    Posts
    105

    Default record id

    I have a logic hook that will fire on before_retrieve to update a field depending on what is entered in to other field of a related module i have the code working all except how to retrieve the id of the record currently open

    PHP Code:
    <?php
    $id
    ="THIS IS WHERE I NEED THE RECORD ID";

    mysql_connect("localhost""username""password");
    mysql_select_db("database");

    $query "SELECT adf21_testecd6testing_ida from adf21_testif21_testing2_c where adf21_test3552esting2_idb='$id' and deleted=0";
    $results mysql_query($query);

    while(
    $row=mysql_fetch_array($results)){
        
    $id2=$row['adf21_testecd6testing_ida'];
        
    $query2="SELECT num1_c, num2_c from adf21_testing_cstm where id_c='$id2'";
        
    $results2 mysql_query($query2);
        while(
    $row2=mysql_fetch_array($results2)){
                
    $num1=$row2['num1_c'];
                
    $num2=$row2['num2_c'];
                
    $num3=$num3+$num2+$num1;
        }
    }
    $update_query="UPDATE adf21_testing2_cstm SET num3_c='$num3' WHERE id='$id'"
    ?>

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

    Default Re: record id

    Try using $bean->id to retrieve it.

    Also, unless you are connecting to another server/database, you should be able to run your query without having to establish a new connection.

    Check out this post for an example:

    http://cheleguanaco.blogspot.com/200...k-example.html
    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)
    ______________________________________________

  3. #3
    blitz2190 is offline Senior Member
    Join Date
    Jul 2009
    Posts
    105

    Default Re: record id

    thanks i knew about the connection thing i was on another machine connecting when i wrote that but ill give $bean->id a try thank you

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

    Default Re: record id

    I just realized you are doing it in a "before_retrieve". Not sure if my suggestion will work in that case, as it may not yet be populated by the time that logic hook fires. I suppose the best way of knowing would be to try it.
    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)
    ______________________________________________

  5. #5
    blitz2190 is offline Senior Member
    Join Date
    Jul 2009
    Posts
    105

    Default Re: record id

    no it does not have an id until after retrieve but i manage to make it work by also setting $bean->field_name to equal what was just entered into the table so that way it would show current information thank you for the help

  6. #6
    rocoyotte is offline Sugar Community Member
    Join Date
    Jul 2009
    Posts
    30

    Default Re: record id

    Try with $_REQUEST var. I've succed with $_REQUEST['record'] to fill the record_id that I needed

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 6
    Last Post: 2009-12-30, 09:43 AM
  2. Replies: 11
    Last Post: 2009-07-22, 07:58 PM
  3. Replies: 8
    Last Post: 2008-06-03, 05:40 AM
  4. Replies: 1
    Last Post: 2008-05-19, 01:44 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
  •