Skip to main content
Question

Supervisor e'mail in custom event

  • Apr 28, 2025 12:05 PM UTC
  • 7 replies
  • 164 views

Forum|alt.badge.img+1
  • Do Gooder (Customer)

Hi,

I need to do custom events sending e’mail notication to supervisor when employee create request 

When creating the event I selected the entity CEmpRequest, a database table C_EMP_REQUEST_TAB. 

Where can I get supervisor's email address when creating an custom event?

7 replies

Forum|alt.badge.img+12
  • Hero (Customer)
  • Apr 29, 2025 11:17 AM UTC

Hey,

Are you using a PLSQL Block event action type at all ? (In which case it is possible).

 

If you’re just using a mail type event, it’d be a lot more complex to do without being able to call some PLSQL logic.

 

If you’re using PLSQL Logic you basically first need to extract the list of supervisor person IDs, which you can do using

 

company_pers_assign_api.get_direct_sup_person_list(company_id_ => company_id_,                                                   emp_no_ => emp_no_,  valid_from_ => sysdate)

 

This gets you the Supervisor(s) Person IDs for the Emp_No and Company_ID you’re parsing as parameters.

 

With those tokenized person IDs, you can fairly easily then check either their SMTP_MAIL_ADDRESS or their Email Type Comm Methods.


Forum|alt.badge.img+1
  • Author
  • Do Gooder (Customer)
  • Apr 30, 2025 12:16 PM UTC

I was hoping that it would be possible to do it with a mail type event. 


Forum|alt.badge.img+12
  • Hero (Customer)
  • Apr 30, 2025 12:25 PM UTC

It might be possible with a custom event attribute, as you can run a plsql block when the event triggers to generate an attribute usable by the event action.

 

Where do you currently store the email addresses? Are those against comm methods on the person record, or is it in the email field of the user record?


Forum|alt.badge.img+1
  • Author
  • Do Gooder (Customer)
  • Apr 30, 2025 12:30 PM UTC

Emails are in the email field of the user record.


Forum|alt.badge.img+12
  • Hero (Customer)
  • May 6, 2025 2:34 PM UTC

Ok so looked into it, and this requires a custom PL/SQL function being created first, as the custom event attribute expects a PL/SQL context, and can’t context switch to straight SQL (so you can’t use a direct SQL statement in it).

 

The following PL/SQL function will accept company_id_ and emp_no_ as parameters, and return a list of  emails from the user records of the direct supervisor(s) of the company/emp_no tuple being parsed as parameters.

 

You’d need to deploy it as a custom util package function and you could then use it in your custom event to automatically retrieve an email list when the event triggers.

 

function get_supervisor_emails_list(company_id_ in varchar2, emp_no_ in varchar2) RETURN VARCHAR2
IS

sup_email_list_ varchar2(4000);

BEGIN

select listagg(ifsapp.fnd_user_property_api.get_value(ifsapp.person_info_api.get_user_id(person_id),'SMTP_MAIL_ADDRESS'), ',' on overflow truncate) within group (order by person_id) as email_list
into sup_email_list_
from ifsapp.person_info_all p
where instr('^'||(select ifsapp.company_pers_assign_api.get_direct_sup_person_list(company_id_,emp_no_) from dual)||'^','^'||p.person_id||'^') > 0;

return dummy_

exception
when others then
return null;

END get_supervisor_emails_list;

 


Forum|alt.badge.img+12
  • Hero (Customer)
  • May 7, 2025 7:51 AM UTC

Sorry, slight error in my code above due to me being a bit hasty with copy pasting

 

function get_supervisor_emails_list(company_id_ in varchar2, emp_no_ in varchar2) RETURN VARCHAR2
IS

sup_person_list_ varchar2(4000);
sup_email_list_ varchar2(4000);


BEGIN

sup_person_list_ := ifsapp.company_pers_assign_api.get_direct_sup_person_list(company_id_,emp_no_);

select listagg(ifsapp.fnd_user_property_api.get_value(ifsapp.person_info_api.get_user_id(person_id),'SMTP_MAIL_ADDRESS'), ',' on overflow truncate) within group (order by person_id) as email_list
into sup_email_list_
from ifsapp.person_info_all p
where instr('^'||sup_person_list_||'^','^'||p.person_id||'^') > 0;

return sup_email_list_;

exception
when others then
return null;

END get_supervisor_emails_list;

 

 


Forum|alt.badge.img+11
  • Hero (Customer)
  • Sep 26, 2025 10:26 AM UTC

I used this function, thank you for posting it.