Question

Custom Event to email customer a report

  • 19 March 2020
  • 3 replies
  • 1139 views

Userlevel 4
Badge +7

We are trying to automate the sending of a completed job record sheet to our customers. We have another customisation which creates a version of the job record sheet and a copy is saved in the report archive and PDF archive.

We attempted to use a system defined event called PDF_REPORT_CREATED. However, we cannot find a way to add custom attributes to this event, so we cannot add the customer’s email address as a parameter.

We then tried to create our own event using ‘PrintJob’ as the logical unit. This allows us to enter a custom attribute to get the customers email address. However, none of the  tables within this logical unit have the PDF FILE to add as an attachment to the email.

I also cannot find an api that will return the PDF so that I could add this as a custom attribute to our event.

 

So - I can either create an email to a specified address with no attachment OR an email containing the PDF report but not a specified email address. What we need as an email with the PDF report attached and the ability to have a custom attribute field in the event (customer’s email address).

 

Any ideas would be greatly appreciated.


3 replies

Userlevel 4
Badge +7

You may write a cursor with custom logic like below to get the emails and use PDF_REPORT_CREATED event to send out the pdf file.

 

DECLARE

  email_ VARCHAR2(200);

  CURSOR get_email IS
    SELECT emaail 
    FROM <...> 
    WHERE <...>;

BEGIN
  
IF <validation to run for the desired report>
  OPEN get_email;
  FETCH get_email
    INTO email_;
  CLOSE get_email;

  command_sys.mail(<from_user>,
                   email_,
                   <subject>,
                   <text>,
                   attach_ => '&PDF_FILE');
                   
END IF;
END;
 

Userlevel 4
Badge +9

@asanka, thanks for your answer! This is very helpful in the case where the action type ‘E-Mail’ and the reports rules aren’t sufficient.

Userlevel 7
Badge +20

We are trying to automate the sending of a completed job record sheet to our customers. We have another customisation which creates a version of the job record sheet and a copy is saved in the report archive and PDF archive.

We attempted to use a system defined event called PDF_REPORT_CREATED. However, we cannot find a way to add custom attributes to this event, so we cannot add the customer’s email address as a parameter.

We then tried to create our own event using ‘PrintJob’ as the logical unit. This allows us to enter a custom attribute to get the customers email address. However, none of the  tables within this logical unit have the PDF FILE to add as an attachment to the email.

I also cannot find an api that will return the PDF so that I could add this as a custom attribute to our event.

 

So - I can either create an email to a specified address with no attachment OR an email containing the PDF report but not a specified email address. What we need as an email with the PDF report attached and the ability to have a custom attribute field in the event (customer’s email address).

 

Any ideas would be greatly appreciated.

Hi @hwilkie ,

 

There are several predefined custom attributes in PDF_REPORT_CREATED event and you can use them to add the customer email.

 

I hope your customisation uses standard IFS logic for create the print job.

 

Following is a code sample how to set event params in PDF_REPORT_CREATED event

DECLARE
send_pdf_info_ VARCHAR2(4000);
BEGIN

send_pdf_info_ := Message_SYS.Construct('PDF');
Message_SYS.Add_Attribute(send_pdf_info_, 'PDF_EVENT_PARAM_1',CUSTOMER_EMAIL);
...
Client_SYS.Add_To_Attr('SETTINGS', send_pdf_info_, print_job_attr_);
Print_Job_API.New(print_job_id_, print_job_attr_);

END;

 

Now you should be able to access the email from PDF_PARAMETER_1 of the event.

 

Hope this helps!

DSJ

Reply