Results 1 to 4 of 4

Thread: Issues with cross module search with enum fields

  1. #1
    kgrise is offline Junior Member
    Join Date
    Jun 2011
    Posts
    7

    Default Issues with cross module search with enum fields

    I'm able to add fields from other modules in the Accounts advanced search as long as they are text fields. I've followed the instructions I've found in the Sugar forums and blogs, etc. I haven't been able to get the SQL query to work properly for enum fields. The possible values are showing up on the front-end, but in the query Sugar is adding an extra single quote to the beginning of the = clause and an N'% at the end so it ends up looking like this:

    WHERE contracts_cstm.preferred_status_c = ''PREFN'%'

    When I actually need:

    WHERE contracts_cstm.preferred_status_c = 'PREF'

    I found one forum post with a similar question, but no one has given a viable answer. Any help is much appreciated.

  2. #2
    kgrise is offline Junior Member
    Join Date
    Jun 2011
    Posts
    7

    Default Re: Issues with cross module search with enum fields

    I figured out the issue. I worked off of an answer in this post:

    http://www.sugarcrm.com/forums/f6/se...modules-57125/

    I was using the incorrect query_type in my SearchFields.php. I had 'default' when it should have been 'format' and once I modified the query slightly (as seen in the above example) it's working correctly.

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

    Default Re: Issues with cross module search with enum fields

    Quote Originally Posted by kgrise View Post
    I figured out the issue. I worked off of an answer in this post:

    http://www.sugarcrm.com/forums/f6/se...modules-57125/

    I was using the incorrect query_type in my SearchFields.php. I had 'default' when it should have been 'format' and once I modified the query slightly (as seen in the above example) it's working correctly.
    Thanks for the update! Could you provide the SearchFields.php entry you added to make the fix?
    John Mertic
    Sugar Community Manager

  4. #4
    kgrise is offline Junior Member
    Join Date
    Jun 2011
    Posts
    7

    Default Re: Issues with cross module search with enum fields

    Here's what I added to my SearchFields.php:

    PHP Code:
    'preferred_status' => array(
            
    'query_type' => 'format',
            
    'operator' => 'subquery',
            
    'subquery' => 'SELECT accounts.id FROM accounts LEFT JOIN contracts ON (accounts.id = contracts.account_id) INNER JOIN contracts_cstm ON (contracts.id = contracts_cstm.id_c) WHERE contracts.deleted = 0 AND contracts_cstm.preferred_status_c IN ({0})',
            
    'db_field' => array(
                
    'accounts.id',
            ),
        ), 

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. cross module search
    By chaostensai in forum Developer Help
    Replies: 7
    Last Post: 2011-05-31, 02:46 PM
  2. Replies: 0
    Last Post: 2011-04-22, 12:12 AM
  3. Cross Module Search
    By romaxl in forum Developer Help
    Replies: 8
    Last Post: 2010-02-12, 04:34 PM
  4. Cross module Search
    By ramji123 in forum General Discussion
    Replies: 1
    Last Post: 2008-09-18, 12:10 PM
  5. Advanced Search Cross Module
    By gsrigg in forum Help
    Replies: 3
    Last Post: 2007-08-13, 11:15 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
  •