Iām trying to create a logic_hook on my Calendar Module on Suitecrm7.9.7 when to appear the emergent window to create the event and I save it, but I made the logic of classic form but is not working
literally, this is my code:
custom/modules/Calendar/logic_hooks.php
<?php
$hook_version = 1;
$hook_array = Array();
$hook_array["after_save"] = Array();
$hook_array["after_save"][] = Array(
//Processing index. For sorting the array.
1,
//Label. A string value to identify the hook.
'after_save example',
//The PHP file where your class is located.
'custom/modules/Calendar/after_save_class.php',
//The class the method is in.
'after_save_class',
//The method to call.
'after_save_method'
);
?>
then : custom/modules/Calendar/after_save_class.php
<?php
if (!defined("sugarEntry") || !sugarEntry) die("Not A Valid Entry Point");
class after_save_class
{
function after_save_method($bean, $event, $arguments)
{
echo "";
}
}
?>
To make sure itās firing, I suggest you better use some PHP directly, for example logging a FATAL error in suitecrm.log.
This is better than outputting the Javascript with the alert, because itās simpler. That way first you determine if the hook is firing, then move on to getting the Javascsipt onto the page.
I understood, and I add a line to write into the log file like this:
<?php
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class after_save_class
{
function after_save_method($bean, $event, $arguments)
{
$GLOBALS["log"]->fatal("*******");
echo "";
}
}
?>
but when I delete the record, I go to see the suitecrm.log file but I canāt find the asterisks, and I tried this in other module and works fineā¦ :S
Also, if you increase your log level to DEBUG you will see some messages in the logs about hooks firing. Maybe that will give you ideas about where to put your code.
You know? I was reviewing the process and I saw the log called suitecrm_1.log and the Message is written (the asterisks) $GLOBALS[ālogā]->fatal("*******");
that minds that are workingā¦ the question is, why not is executing my javascript code echo "";
??..maybe could be 'cause is very fast the process? :S u.u
I donāt think you can just start trying to inject HTML or Javascript from a hook, theyāre not meant for that. You should be overriding a view for that kind of thingā¦
But do you really need that Javascript? What exactly do you want the hook to do?
exactly, what I need is, when one record is deleted from Meetings module, I need that appears a popup, just that, that popup shows the googleās screen for agree some user to delete the event from google calendar and agree to the access,
do you understand?
in fact, my code is this:
that code is working fine but, the idea is that it should be fired after delete or remove relationship of an event recordā¦
Hooks can be called from other places that donāt even have a UI. For example, when you manipulate beans from a Scheduler, or from the API.
So a hook is not a good place to try and play with the UI. Try finding out which view object you can override, and intercept the action sooner (for example, when the button is clicked), not when the record is saved.
A different approach (I donāt know if it could work) would be to try and send that link to the Notification balloon on the top menu. I donāt know how to do it but I think you could find some posts here on the forums with code samples for that. This way, you could do it from the hook, writing the notification in the database, and the UI would show it on the next screen refresh.