<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://sugarclub.sugarcrm.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to customise filter search condition to use subquery in sugar 7.x?</title><link>https://sugarclub.sugarcrm.com/dev-club/f/questions-answers/1008/how-to-customise-filter-search-condition-to-use-subquery-in-sugar-7-x</link><description>hey champions, As you know, back in sugar 6.x, we could edit the searchFields.php to add &amp;quot;subquery&amp;quot; to customise the search condition. which was quite flexible. e.g. &amp;#39;favorites_only&amp;#39; =&amp;gt; array ( &amp;#39;query_type&amp;#39; =&amp;gt; &amp;#39;format&amp;#39; , &amp;#39;operator&amp;#39; =&amp;gt; &amp;#39;subquery&amp;#39; , &amp;#39;subquery</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to customise filter search condition to use subquery in sugar 7.x?</title><link>https://sugarclub.sugarcrm.com/thread/19303?ContentTypeID=1</link><pubDate>Wed, 02 Sep 2020 16:07:25 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:fa969c00-2b9a-4f89-8016-43e3727fa0ec</guid><dc:creator>Angel Martinez</dc:creator><description>&lt;p&gt;Hello &lt;a href="/members/bglcorp"&gt;Ron Lesh&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Did you find any solution to this?&lt;/p&gt;
&lt;p&gt;Regards,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Angel M.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to customise filter search condition to use subquery in sugar 7.x?</title><link>https://sugarclub.sugarcrm.com/thread/3991?ContentTypeID=1</link><pubDate>Wed, 20 Sep 2017 02:52:04 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:9bba6738-b69c-4e23-b2eb-a4fb4bc9bbd6</guid><dc:creator>Ron Lesh</dc:creator><description>&lt;p&gt;Hey Andr&amp;eacute;,&lt;/p&gt;&lt;p&gt;Thanks again for your help. Seems not easy. but I definitely will find a time and try it out.&lt;/p&gt;&lt;p&gt;This sounds like a solution to &amp;quot;add a custom filter which does join/saw sql&amp;quot;. However, what if i want to customise the search field, which could be created / added as one of the condition?&lt;/p&gt;&lt;p&gt;e.g &amp;quot;Assigned To&amp;quot;.&lt;/p&gt;&lt;p&gt;currently, it only has the option of &amp;quot;is any of&amp;quot; and &amp;quot;is not any of&amp;quot;. how could i customise it to have the option of &amp;quot;is not empty&amp;quot;?&amp;nbsp;&lt;/p&gt;&lt;p&gt;e.g. &amp;quot;Open Only&amp;quot;&lt;/p&gt;&lt;p&gt;&amp;#39;open_only&amp;#39; =&amp;gt; &lt;br /&gt; array (&lt;br /&gt; &amp;#39;dbFields&amp;#39; =&amp;gt; &lt;br /&gt; array (&lt;br /&gt; 0 =&amp;gt; &amp;#39;status&amp;#39;,&lt;br /&gt; ),&lt;br /&gt; &amp;#39;type&amp;#39; =&amp;gt; &amp;#39;bool&amp;#39;,&lt;br /&gt; &amp;#39;vname&amp;#39; =&amp;gt; &amp;#39;LBL_OPEN_ITEMS&amp;#39;,&lt;br /&gt; ),&lt;/p&gt;&lt;p&gt;the option is &amp;quot;is true or false&amp;quot;. i understand it should be like this. however, because back in years ago, we completely changed the value of &amp;quot;case_status_dom&amp;quot;. i am guessing by default, when it is selected as true, sugar would try to look for status which is one of/ is not one of those stock status value. In our case, i would need to change it to target our custom status.&lt;/p&gt;&lt;p&gt;thank you very much.&lt;/p&gt;&lt;p&gt;regards,&lt;/p&gt;&lt;p&gt;Ron&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to customise filter search condition to use subquery in sugar 7.x?</title><link>https://sugarclub.sugarcrm.com/thread/3990?ContentTypeID=1</link><pubDate>Tue, 19 Sep 2017 13:42:26 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:0b2a8a7b-bc29-4420-8a95-122e44a25451</guid><dc:creator>Andr&amp;#233; Lopes</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;a href="https://sugarclub.sugarcrm.com/members/bglcorp"&gt;Ron Lesh&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;There is no way to achieve that through filter metadata.&lt;/p&gt;&lt;p&gt;Instead you have to extends the class FilterApi (clients/base/api/FilterApi.php). Inside that class take a look at the method &amp;quot;addFavoriteFilter&amp;quot; (it refers to $favorite defined at custom/modules/&amp;lt;ModuleName&amp;gt;/clients/base/filters/default/default.php).&lt;/p&gt;&lt;p&gt;In the inherited class you have to override the method &amp;quot;addFilters&amp;quot; the way you can inject some joins/raw sql into SugarQuery $q object according to a new filter definition you are going to create.&lt;/p&gt;&lt;p&gt;At last&amp;nbsp;you can modify your filter definition in order to specify the new filter definition.&lt;/p&gt;&lt;p&gt;Kind regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>