Menu
SuiteCRM Pull Request Party hosted by SalesAgility
Welcome, Guest
Username: Password: Remember me

TOPIC: Get advanced filter applied value

Get advanced filter applied value 3 days 2 hours ago #76352

  • sagardundle
  • sagardundle's Avatar
  • Offline
  • New Member
  • Posts: 5
  • Karma: 0
Hi,

i am trying to get advanced applied filter value "assigned username" in custom logic hook created for leads.
Based on that filter value i am going to show sum of amount according to assigned username.
Kindly help

Thanks,
Sagar
The administrator has disabled public write access.

Get advanced filter applied value 2 days 22 hours ago #76364

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 8789
  • Thank you received: 1337
  • Karma: 323
Sorry, I don't understand.

Which kind of logic hook is this?

Do you just need to know the "assigned user" name? Or what to do you need to do with it next?

And please always state your version of SuiteCRM.

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.

Get advanced filter applied value 2 days 21 hours ago #76371

  • sagardundle
  • sagardundle's Avatar
  • Offline
  • New Member
  • Posts: 5
  • Karma: 0
SUITECRM VERSION: 7.10.7, SUGAR VERSION: 6.5.25

i have created a logic hook for leads in following folder structure
\custom\modules\Leads\logic_hook.php
this file contains the following code:
$hook_array['after_ui_frame'][] = Array(1, 'Some description of what you are doing',     'custom/modules/Leads/SumfieldAmount__LogicHook.php','CustomAmountLead', 'functionToDisplayTheSumLead');

This logic hook calls SumfieldAmount__LogicHook.php file located in following path:
\custom\modules\Leads\logic_hook.php\SumfieldAmount__LogicHook.php

It contains the following code to find the sum of "oppurtunity amount" field in listview -
class CustomAmountLead {
           function functionToDisplayTheSumLead(&$focus, $event) {	
                if ($GLOBALS['action'] == 'index' || $GLOBALS['action'] == 'ListView') {
                        $yourSum = self::$yourSum; // TODO: maybe you want to add some formatting to numbers, dates, etc.
						global $db;

					//$id =  $this->bean->id;

					$query = "SELECT SUM(opportunity_amount) AS Amount FROM leads";

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

					$row = $db->fetchByAssoc($result);
					foreach($row as $value){
						
                        echo <<<EOHTML
<script type="text/javascript">
<!--
$('<td nowrap="nowrap" class="paginationActionButtons"><b>Grant Total: {$value}</b></td>').insertBefore('.paginationChangeButtons');
-->
</script>
EOHTML;
					} //end of foreach
                }
        } // end of functionToDisplayTheSum

} // end of YourPHPClassName
}


Now i get the following code run correctly to find the sum of opportunity amount in list view of leads.

But when i apply advanced filter i apply filter by "assigned username" so i need to get the sum of "opportunity amount" by assigned username. For Example:
if i apply advance filter in leads listview by "assigned username". I select sagar as as assigned username, then i should get the sum of "opportunity amount" of "sagar" in leads listview.
Last Edit: 2 days 16 hours ago by pgr. Reason: add code tags
The administrator has disabled public write access.

Get advanced filter applied value 2 days 15 hours ago #76391

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 8789
  • Thank you received: 1337
  • Karma: 323
Ok, now I understand.

Are you using a debugger? If so, try looking at what session variables you have available at that point in the code. If you can find the data structures that describe the current filter, then you can work from there to add a "WHERE" clause to your SQL.

You might also want to check out this example, it's a different approach to a similar problem:
suitecrm.com/suitecrm/forum/developer-he...ay-total-lead-scores

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.

Get advanced filter applied value 2 days 2 hours ago #76414

  • sagardundle
  • sagardundle's Avatar
  • Offline
  • New Member
  • Posts: 5
  • Karma: 0
No, i am not using debugger. I am debugging using print_r() and exit.

I am trying to find the data structure of current filter but not able to get it.

I printed $bean and $focus but it all contains the leads listview array not the current filter data.

kindly help me
The administrator has disabled public write access.

Get advanced filter applied value 2 days 2 hours ago #76416

  • sagardundle
  • sagardundle's Avatar
  • Offline
  • New Member
  • Posts: 5
  • Karma: 0
The current filter is also not saved. If it was saved then i can get the data from database and query using where clause.
I googled a lot but could't got any solution to get data structure of current unsaved filter.

Please help me.
The administrator has disabled public write access.

Get advanced filter applied value 1 day 20 hours ago #76447

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 8789
  • Thank you received: 1337
  • Karma: 323
I would love to help you further, but I simply don't know.

Maybe the $_SESSION variables have something useful for you (REQUEST, etc).

Also try that other example I gave you, you might have access to other things in there. It's a different context, not a logic hook, so it's more tied in to the regular display of screens.

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.
Time to create page: 0.137 seconds
Powered by Kunena Forum