I have written the logic hook to send email notification but keeps giving this error message from the php file “Could not find Users within the department NC is issued to”, I don’t understand why it to saying that $dept_array is equivalent to zero(0). This is the name of the relationship (dept_department_nccas_nc_case)’; not sure if my syntax is incorrect or what the case maybe.
if(count($dept_array)==0){
/log error/
$GLOBALS[‘log’]->fatal("Could not find the department NC was issued to: ". $bean->name);
}else{
/* Get email of users within the Department NC is issued to */
$user_array = $dept_array[0]->get_linked_beans(‘dept_department_users’,‘User’);
if(count($user_array)==0){
/log error/
$GLOBALS[‘log’]->fatal("Could not find Users within the department NC is issued to: ". $bean->name);
}else{
$address=getDepartmentUsersEmail($user_array);
}
/*Get the Department NC was raised by */
$raised_dept_array= $bean->get_linked_beans('dept_department_nccas_nc_case_1','dept_Department_sugar');
if(count($raised_dept_array)==0){
/*log error*/
$GLOBALS['log']->fatal("Could not find the department NC was raised by: ". $bean->name);
}else {
/*Get email of users within the Department NC is raised by*/
$raised_user_array = $raised_dept_array[0]->get_linked_beans('dept_department_users','User');
if(count($raised_user_array)==0){
/*log error*/
$GLOBALS['log']->fatal("Could not find Users within the department NC is raised by: ". $bean->name);
}
else {
$r_user_address = getDepartmentUsersEmail($raised_user_array);
}
}
I see that you are using two different relationships:
. dept_department_nccas_nc_case
. dept_department_nccas_nc_case_1
Are they supposed to be different?
Are those both the correct names of the relationships
Is the name of the module (dept_Department_sugar) correct?
Is the name of the bean object ($bean) correct?
Can you try to output to screen the $bean object (then exit; otherwise the flow will continue) to see its contents. I see that $bean->name appears to be empty in the message output.
dept_Department_sugar is the name of a php file with the fields and $bean->name is not empty; it printed out the subject of the nc case. Yes they are no different relationships
I’m not understanding because the same relationship that I used that’s the link definition in cached vardefs that I used; but some how the count is still zero. Yes I did look at that forum
If you create a relationship, and then delete it and then recreate it you may end up in trouble not finding the correct relationship that you have to use.
Please try your code first with dept_department_nccas_nc_case and check if it works. Then modify the cde and try with dept_department_nccas_nc_case_1 (the difference being the “_1” at the end)
That didn’t work either. And the only error is this
Mon Apr 15 07:08:57 2019 [6960][e19f62c5-9f87-02bc-204f-5a57c41e1cd1][FATAL] Could not find the department NC was issued to: hjggggf
Mon Apr 15 07:08:57 2019 [6960][e19f62c5-9f87-02bc-204f-5a57c41e1cd1][FATAL] Could not find the department NC was issued to: hjggggf
" hjggggf" is the subject of the nc case that I entered and that’s the result showed suitecrm.log
Thanks everyone for your assistance but the relationship name was the tricky that caused the error; eberything is working ok now. Only issue is that email notifications are coming twice