Hi,
I’m trying to create an after_retrieve logic hook to show a popup message in detail view when my custom field candidate_no contains particular string values.
I keep getting syntax errors when trying to create the logic hook.
The code is as follows
<?php
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class popup_warning_class
{
function popup_warning_method($bean, $event, $arguments)
{
$candidate_no = $_REQUEST['candidate_no'];
if $candidate_no = 1234;
die('testing');
}
}
?>
That’s basic PHP syntax, the IF requires parenthesis around the expression.
if ($candidate_no == 1234) {
die('Testing');
}
Then I also added brackets for the code to be executed when the expression is true. Not strictly necessary if you’re executing just one command, but good practice.
You also need a double == for comparison, otherwise you’re attributing (changing the variable on the left, not testing it). This can be a really confusing bug, pay attention to it.