Hello
I would like to know if its exist a function for obtain the id of the current module ? like :
$current_user_id=$GLOBALS['current_user']->id;
I try to obtain the ID when I am on my prospect view.
Cordialy,
Hello
I would like to know if its exist a function for obtain the id of the current module ? like :
$current_user_id=$GLOBALS['current_user']->id;
I try to obtain the ID when I am on my prospect view.
Cordialy,
Hi
try putting this in the beggining of your code:
global $current_user
and then you should be able to access the whole bean from that, including
$current_user->id
unfortunately it doesn’t work
class sendAlert
{
function sendAlert($bean, $event, $arguments)
{
global $current_user
$result = BeanFactory::newBean(‘Alerts’);
$result->name = ‘New Prospect’;
$result->description = ‘Vous venez de créer un prospect !’;
$result->target_module = ‘Leads’;
$result->url_redirect = ‘index.php?module=Leads&action=DetailView&record=’.$current_user->id.’’;
$result->assigned_user_id = $GLOBALS[‘current_user’]->id;
$result->type = ‘info’;
$result->is_read = 0;
$result->save();
}
}
I think I find the solution
with $bean->id its working
You need a semicolon (;
) after global $current_user
$bean-id
is the id of the Alert bean, not of a user
you should reference the user id as $current_user->id
, not using GLOBALS
Yes thank you for your advice
I have the id of the alert, the id of the user but I don’t have find the id of this leads
You have to give me more context. Is this in a logic hook? Exactly how did you define it?
What are you trying to achieve?
Hi,
I try to do a alerts, my objective in to obtain a notification and when I click on the notification I have a redirection until my Details View.
Its for that I need the ID of my record lead for complete this line :
$result->url_redirect = 'index.php?module=Leads&action=DetailView&record=';
in my logic hooks I write this
logic_hooks.php
<?php
// Do not store anything in this file that is not part of the array or the hook version. This file will
// be automatically rebuilt in the future.
$hook_version = 1;
$hook_array = Array();
// position, file, function
$hook_array['before_save'] = Array();
$hook_array['before_save'][] = Array(1, 'Leads push feed', 'modules/Leads/SugarFeeds/LeadFeed.php','LeadFeed', 'pushFeed');
$hook_array['before_save'][] = Array(77, 'updateGeocodeInfo', 'modules/Leads/LeadsJjwg_MapsLogicHook.php','LeadsJjwg_MapsLogicHook', 'updateGeocodeInfo');
$hook_array['after_save'] = Array();
$hook_array['after_save'][] = Array(77, 'updateRelatedMeetingsGeocodeInfo', 'modules/Leads/LeadsJjwg_MapsLogicHook.php','LeadsJjwg_MapsLogicHook', 'updateRelatedMeetingsGeocodeInfo');
$hook_array['after_save'][] = Array(2, 'send alert to user', 'custom/modules/Leads/LogicHooks/SendAlert.php','sendAlert', 'sendAlert');
?>
and in my SendAlert.php
<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
class sendAlert
{
function sendAlert($bean, $event, $arguments)
{
global $current_user;
$result = BeanFactory::newBean('Alerts');
$result->name = 'Nouveau lead!';
$result->description = 'Vous venez de créer un lead!';
$result->target_module = 'Leads';
$result->url_redirect = 'index.php?module=Leads&action=DetailView&record=';
$result->assigned_user_id = $current_user->id;
$result->type = 'info';
$result->is_read = 0;
$result->save();
}
}
?>
Cordialy,
If you are in a Leads logic hook, then that $bean
parameter is the current lead, so you should be able to use $bean->id
for the Bean id
yes its working now with this parameter
Thank you