Results 1 to 3 of 3

Thread: Problem to insert records in logic hooks

  1. #1
    sugar78 is offline Junior Member
    Join Date
    Sep 2008
    Posts
    4

    Default Problem to insert records in logic hooks

    We are using SugarCRM 5.1 version and I was creating record in a Notes module in before_save logic hook of Cases module. But it gives me the following error in the error log. Can someone help me to decipher as what I am doing wrong?

    PHP Fatal error: Call to a member function query() on a non-object in C:\\SugarCRM\\sugarcrm-5.0.0f\\htdocs\\sugarcrm\\custom\\include\\Cases\\ CaseValidation.php on line 67, referer: http://127.0.0.1/sugarcrm/index.php

    I have a class CaseValidation logic hook in Cases module. We tried to move values from one field to the other in the logic hook and it works fine. But the when I create Notes records using logic hooks, it gives me fatal error at query stmt.


    $parentid = $bean->id;
    $id= create_guid();
    echo $id;
    echo $parentid;
    echo "reached here";
    $timestamp=time($bean->date_entered);
    echo $timestamp;

    $entered_date = date("Y-m-d H:i:s",$timestamp);
    echo $entered_date;


    $query = "INSERT INTO notes (id,name,description,parent_type,parent_id,date_en tered,date_modified) "."VALUES ('".$id."','name','TEST','Cases','".$parentid."',' ".$entered_date."','".$entered_date."');";
    echo $query;

    $result = $db->query($query);

  2. #2
    jmertic is offline Sugar Community Manager
    Join Date
    Dec 2007
    Posts
    2,224

    Default Re: Problem to insert records in logic hooks

    Change the line

    $result = $db->query($query);

    to:

    $result = $GLOBALS['db']->query($query);

  3. #3
    sugar78 is offline Junior Member
    Join Date
    Sep 2008
    Posts
    4

    Default Re: Problem to insert records in logic hooks

    thanks it works

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Logic Hook: How to recognise new records
    By twguk1516 in forum Developer Help
    Replies: 1
    Last Post: 2008-07-07, 12:38 PM
  2. Problem with importing records
    By johnol in forum Help
    Replies: 16
    Last Post: 2006-08-09, 02:40 PM
  3. export ‘checked’ records problem
    By yh924 in forum Classifieds
    Replies: 6
    Last Post: 2006-02-14, 06:24 AM
  4. 4.0.1 Installation Problem
    By clawton in forum Help
    Replies: 14
    Last Post: 2006-02-13, 04:17 PM
  5. Email Attachment Problem
    By George in forum Developer Help
    Replies: 1
    Last Post: 2005-05-18, 05:33 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
  •