Results 1 to 2 of 2

Thread: Logic Hook is working far too well issue

  1. #1
    routledge is offline Sugar Community Member
    Join Date
    Jan 2008
    Location
    London
    Posts
    98

    Default Logic Hook is working far too well issue

    Hello everyone and thanks for reading. I have implemented a logic hook to prevent fields being NULL.

    Ok you may be confused by this, i will explain. The implimentation of sugar works across multiple databases so to make thisgs simpler I matched the sugar table with a table from another database by use od MySQL Views. It all works very well with all issues ironed out except one.

    On the donor database many fields cannot be set to null. The reason is that the donor table is used by many other websites and applications, which will break if these fields are set to null.

    I have got round the insert problems when trying to insert null onto the view linking to this table with the following code.

    <?php

    class ContactNullFields

    {

    function updateContactFields(&$bean, $event, $arguments)
    {
    if ($bean->department===NULL);
    unset($bean->department);
    }

    }

    ?>

    This code works brilliantly on insert, but when you try to update the field 'department' the update does not happen.

    Any ideas as to why this code is making the update fail as when the data that will be inserted will not be NULL.

    Regards

    John

  2. #2
    routledge is offline Sugar Community Member
    Join Date
    Jan 2008
    Location
    London
    Posts
    98

    Default Re: Logic Hook is working far too well issue

    Fixed this now allows null to be empty strings in the database

    <?php

    class ContactNullFields

    {

    function updateContactFields(&$bean, $event, $arguments)
    {
    if ($bean->department===NULL)
    {
    unset($bean->department);
    }
    }

    }

    ?>

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Logic Hook Issue
    By Glitch in forum Developer Help
    Replies: 6
    Last Post: 2009-07-17, 07:31 AM
  2. Logic hook to set a date (not working)
    By LechnerJ in forum Developer Help
    Replies: 5
    Last Post: 2009-06-15, 07:09 PM
  3. Issue with Logic Hook and get_linked_beans/save.
    By jjwdesign in forum Developer Help
    Replies: 1
    Last Post: 2009-03-03, 12:59 PM
  4. Timezone issue in logic hook
    By felixrong in forum Developer Help
    Replies: 6
    Last Post: 2009-02-25, 07:59 AM
  5. logic hook issue
    By jungler in forum Developer Help
    Replies: 10
    Last Post: 2008-03-13, 06:07 AM

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
  •