Skip to main content

Hi all,

In IFS10 UPD4 I have developed an automated process to take an authorised Purchase Requisition, convert it to a Purchase Order, release it and then email the requisitioner with the order details. I would like to attach a PDF copy of the PO (or send one from another Event Action) but have not managed to figure out how to do it.

I have an Event configured against the PURCHASE_ORDER_TAB table that triggers when the PO is Released and then an Event Action E-mail to inform the requisitioner, but there are no Event linked attachments available to attach.

Does anyone know how to code the printing and emailing functionality?

Thanks in advance,

Ged Pierce.

I’d also be interested to know how an event action might be built to auto-print a specific report.  We’re looking for other purposes but it ties in with the first part of @GPIE ‘s question.

Nick


For emailing, you can setup an event action based on the creation of the PDF object. Your IFS Apps 10 system should have an application defined event named “PDF_REPORT_CREATED” in the “PrintJob” Logical Unit. You can add an event action to it to email the report.

 

For auto-printing, you could create an event action that would use a small amount of PL/SQL to create a print job. You would need to make some decisions on what printer to send the output to based on user, location, etc.

 


> you could create an event action that would use a small amount of PL/SQL to create a print job

And that’s exactly the difficulty...what that would look like, what API(s) might be used, etc.  I’m hoping that someone who has done it previously might be able to provide some guidance rather than needing to start from zero.

Any heroes out there? :fingers_crossed_tone1:


@NickPorter

search this forum for “attribute string” and “batch print work instruction”. That should give you the info you need. You will end up with something like this. 

procedure printWorkInstruction(order_no_ varchar2, release_no_ varchar2, sequence_no_ varchar2, printer_id_ varchar2)
is
layout_name_ varchar(2000):='ShopOrdWiRep.rdl';
report_id_ varchar2(2000):= 'SHOP_ORD_WI_REP';
report_attr_ varchar2(2000);
parameter_attr_ varchar2(2000);
distribution_list_ varchar2(2000):= '';
instance_attr_ varchar2(2000);
print_job_id_ varchar2(2000);
print_attr_ varchar2(2000):= '';
result_key_ varchar2(2000);
attr_ varchar2(2000);
begin

report_attr_:= 'REPORT_ID'||chr(31)||report_id_||chr(30)||'LAYOUT_NAME'||chr(31)||layout_name_||chr(30);
parameter_attr_:= 'ORDER_NO'||chr(31)||order_no_||chr(30)||'RELEASE_NO'||chr(31)||release_no_||chr(30)||'SEQUENCE_NO'||chr(31)||sequence_no_||chr(30);

archive_api.New_Client_Report(result_key_, report_attr_, parameter_attr_, distribution_list_, print_attr_);
archive_api.Get_Info(instance_attr_,parameter_attr_,result_key_);

attr_:= 'PRINTER_ID'||chr(31)||printer_id_||chr(30);
print_job_api.New(print_job_id_,attr_);

client_sys.Add_To_Attr('PRINT_JOB_ID',print_job_id_,instance_attr_);
client_sys.Add_To_Attr('RESULT_KEY',result_key_,instance_attr_);

print_job_contents_api.New_Instance(instance_attr_);

print_Job_API.Print(print_job_id_);

commit;

end printWorkInstruction;

 


@Hans Andersen thanks!  In the words of a wise man... “Flippin’ sweet!”

Very helpful.

Nick


Instead of using hard coded escape characters (30 & 31) you might consider using the IFS supplied procedure in the entire block.

 

procedure printWorkInstruction(order_no_ varchar2, release_no_ varchar2, sequence_no_ varchar2, printer_id_ varchar2)
is
layout_name_ varchar(2000):='ShopOrdWiRep.rdl';
report_id_ varchar2(2000):= 'SHOP_ORD_WI_REP';
report_attr_ varchar2(2000) := '';
parameter_attr_ varchar2(2000) := '';
distribution_list_ varchar2(2000):= '';
instance_attr_ varchar2(2000) := '';
print_job_id_ varchar2(2000) := '';
print_attr_ varchar2(2000):= '';
result_key_ varchar2(2000) := '';
attr_ varchar2(2000) := '';
begin
Client_Sys.Clear_Attr(report_attr_);
Client_Sys.Clear_Attr(parameter_attr_);
Client_Sys.Clear_Attr(attr_);

Client_Sys.Set_Item_Value('REPORT_ID', report_id, report_attr_);
Client_Sys.Set_Item_Value('LAYOUT_NAME', layout_name_, report_attr_);

Client_Sys.Set_Item_Value('ORDER_NO', order_no_, parameter_attr_);
Client_Sys.Set_Item_Value('RELEASE_NO', release_no_, parameter_attr_);
Client_Sys.Set_Item_Value('SEQUENCE_NO', sequence_no_, parameter_attr_);

archive_api.New_Client_Report(result_key_, report_attr_, parameter_attr_, distribution_list_, print_attr_);
archive_api.Get_Info(instance_attr_, parameter_attr_, result_key_);

Client_Sys.Set_Item_Value('PRINTER_ID', printer_id_, attr_);
print_job_api.New(print_job_id_,attr_);

client_sys.Set_Item_Value('PRINT_JOB_ID', print_job_id_, instance_attr_);
client_sys.Set_Item_Value('RESULT_KEY', result_key_, instance_attr_);

print_job_contents_api.New_Instance(instance_attr_);

print_Job_API.Print(print_job_id_);

commit;
end printWorkInstruction;

 

 


You can do this is two ways. Use an event action or using a report rule.

In both cases, you need to create a print job as described in this discussion. One thing to add here is that as you only want to email the PDF report and not to print it, you can use the NO_PRINTOUT predefined logical printer. As the name says, this will only create the PDF and archive it.

if you plan to use an event action, then you will have to pass values, to the PDF_EVENT_PARAM1 - 10 when creating your print job. These will hold the values to be use in the event action for the mail to, from,  subject and body etc. You need to pass these values in the attr_ when calling the print_job_api.new under SETTINGS attr string.

e.g.

!PDF

$PDF_ARCHIVING=TRUE
$PDF_EVENT_PARAM_1=Chanaka.amarasekara@ifsworld.com
$PDF_EVENT_PARAM_2=CHA
$PDF_EVENT_PARAM_3=CHA
$PDF_EVENT_PARAM_4=CHA-E-Mail
$PDF_EVENT_PARAM_5=Chanaka Amarasekara
$PDF_EVENT_PARAM_6=P740245
$PDF_EVENT_PARAM_8=CHA-E-Mail
$REPLY_TO_USER=CHAALK

 

Then you need to create an event action type of email and use the PDF_EVENT_PARAMS to configure the event action.

When the print job is successfully completed (check from Print Manger) the event is triggered and the email is sent.

 

The other way is that, if you have all the details to be included in the generated XML data. That is the email to be sent, the info that should be included in the title and body etc. Then you can simply create a print job to the NO_PRINTOUT logical printer. Here you don’t have to worry about EVENT_PARAMS so no need to include those. Then simple add a report rule of type send email. Then add the info like to, from, subject and body from the XML data using the xpaths. I think this is the easies way. Also you have the flexibility of sending the mail depending on conditions using the data itself. See the following link for more details.

https://docs.ifs.com/techdocs/Foundation1/040_administration/250_operational_reporting/070_report_rules/default.htm

Hope this helps.


I've done the following for documents where we want them to be send automatically:

  • Create an event that prints the document with Event Parameters to ensure I can determine if it must be mailed.
  • Then use ‘Emailing Report using Event Action’ to actually send the email. I prefer this way above the report rule.

I've used existing API to look how IFS handles this in the existing RMB's, then I just changed this code and put in an event. A good example is PURCHASE_ORDER_API.EMAIL__.


Thanks everyone for your comments.

I had looked at the PDF event action but there seems to be a bug (currently with IFS support) where the attachment selection of event generated documents is greyed out. However, it didn’t help me generate the PDF in the first place.

I am on holiday today so will review the code samples tomorrow.

Again, thank you all.

Ged.


After digging around in the Server Trace tab of Debug Console (after reading this thread) I have a working solution:

First, create the PDF Parameters but including SEND_PDF and SEND_PDF_TO ...

DECLARE
P0_ VARCHAR2(32000) :=
'SEND_PDF'||CHR(31)||'TRUE'||CHR(30)||
'SEND_PDF_TO'||CHR(31)||'user.name@domain.com'||CHR(30)||
'PDF_ARCHIVING'||CHR(31)||'TRUE'||CHR(30)||
'PDF_EVENT_PARAM_1'||CHR(31)||''||CHR(30)||
'PDF_EVENT_PARAM_2'||CHR(31)||VENDOR_NO||CHR(30)||
'PDF_EVENT_PARAM_3'||CHR(31)||CONTRACT||CHR(30)||
'PDF_EVENT_PARAM_4'||CHR(31)||''||CHR(30)||
'PDF_EVENT_PARAM_5'||CHR(31)||'User Name'||CHR(30)||
'PDF_EVENT_PARAM_6'||CHR(31)||ORDER_NO||CHR(30)||
'REPLY_TO_USER'||CHR(31)||'USER_ID'||CHR(30);
P1_ VARCHAR2(32000) := ORDER_NO;
P2_ VARCHAR2(32000) := '';
P3_ VARCHAR2(32000) := '*';
P4_ VARCHAR2(32000) := CONTRACT;
P5_ VARCHAR2(32000) := NULL;
P6_ VARCHAR2(32000) := VENDOR_NO;
BEGIN
IFSAPP.PURCHASE_ORDER_API.GENERATE_PDF_PARAMETERS (P0_ , P1_ , P2_ , P3_ , P4_ , P5_ , P6_ );
END;

Then run the Print Job code, modified (from the code shown in this thread) to include the Purchase Order Report requirements ...

DECLARE
LAYOUT_NAME_ VARCHAR(2000):='PURCHASEORDERPRINTREP.RDL';
REPORT_ID_ VARCHAR2(2000):= 'PURCHASE_ORDER_PRINT_REP';
REPORT_ATTR_ VARCHAR2(2000);
PARAMETER_ATTR_ VARCHAR2(2000);
DISTRIBUTION_LIST_ VARCHAR2(2000):= '';
INSTANCE_ATTR_ VARCHAR2(2000);
PRINT_JOB_ID_ VARCHAR2(2000);
PRINT_ATTR_ VARCHAR2(2000);
PRINTER_ID_ VARCHAR2(2000):= 'PDF_PRINTER';
PUR_ORDER_PRINT_OPTION_ VARCHAR(2000) := 'Order';
ORDER_NO_ VARCHAR2(2000):= ORDER_NO;
RESULT_KEY_ VARCHAR2(2000);
ATTR_ VARCHAR2(2000);
BEGIN
REPORT_ATTR_:= 'REPORT_ID'||CHR(31)||'PURCHASE_ORDER_PRINT_REP'||CHR(30)||'LAYOUT_NAME'||CHR(31)||'PURCHASEORDERPRINTREP.RDL'||CHR(30);
PARAMETER_ATTR_:= 'ORDER_NO_LIST'||CHR(31)||ORDER_NO_||CHR(30)||'PUR_ORDER_PRINT_OPTION'||CHR(31)||PUR_ORDER_PRINT_OPTION_||CHR(30);
ARCHIVE_API.NEW_CLIENT_REPORT(RESULT_KEY_, REPORT_ATTR_, PARAMETER_ATTR_, DISTRIBUTION_LIST_, PRINT_ATTR_);
ARCHIVE_API.GET_INFO(INSTANCE_ATTR_,PARAMETER_ATTR_,RESULT_KEY_);
ATTR_:= 'PRINTER_ID'||CHR(31)||PRINTER_ID_||CHR(30);
PRINT_JOB_API.NEW(PRINT_JOB_ID_,ATTR_);
CLIENT_SYS.ADD_TO_ATTR('PRINT_JOB_ID',PRINT_JOB_ID_,INSTANCE_ATTR_);
CLIENT_SYS.ADD_TO_ATTR('RESULT_KEY',RESULT_KEY_,INSTANCE_ATTR_);
PRINT_JOB_CONTENTS_API.NEW_INSTANCE(INSTANCE_ATTR_);
PRINT_JOB_API.PRINT(PRINT_JOB_ID_);
END;

This process created the Report Archive, the PDF Archive and emails the PDF to the recipient.

The downside of using this method is not being able to control the text or layout in the email ...

 


This code can be run to both generate the PDF parameters and send the PDF in one hit, to either negate the need to create the PDF parameters or to override the existing PDF parameters. Note the expansion of the ATTR_ data.

Now it would be nice to be able to change the email subject and body.

DECLARE
LAYOUT_NAME_ VARCHAR(2000):='PurchaseOrderPrintRep.rdl';
REPORT_ID_ VARCHAR2(2000):= 'PURCHASE_ORDER_PRINT_REP';
REPORT_ATTR_ VARCHAR2(2000):= '';
PARAMETER_ATTR_ VARCHAR2(2000):= '';
DISTRIBUTION_LIST_ VARCHAR2(2000):= '';
INSTANCE_ATTR_ VARCHAR2(2000):= '';
PRINT_JOB_ID_ VARCHAR2(2000):= '';
PRINT_ATTR_ VARCHAR2(2000):= '';
PRINTER_ID_ VARCHAR2(2000):= 'PDF_PRINTER';
PUR_ORDER_PRINT_OPTION_ VARCHAR(2000) := 'Order';
--PUR_ORDER_PRINT_OPTION_ VARCHAR(2000) := 'Order Work Copy';
ORDER_NO_ VARCHAR2(2000):= ORDER_NO;
RESULT_KEY_ VARCHAR2(2000):= '';
ATTR_ VARCHAR2(2000):= '';
BEGIN
REPORT_ATTR_:= 'REPORT_ID'||CHR(31)||'PURCHASE_ORDER_PRINT_REP'||CHR(30)||'LAYOUT_NAME'||CHR(31)||'PurchaseOrderPrintRep.rdl'||CHR(30);
PARAMETER_ATTR_:= 'ORDER_NO_LIST'||CHR(31)||ORDER_NO_||CHR(30)||'PUR_ORDER_PRINT_OPTION'||CHR(31)||PUR_ORDER_PRINT_OPTION_||CHR(30);
ARCHIVE_API.NEW_CLIENT_REPORT(RESULT_KEY_, REPORT_ATTR_, PARAMETER_ATTR_, DISTRIBUTION_LIST_, PRINT_ATTR_);
ARCHIVE_API.GET_INFO(INSTANCE_ATTR_,PARAMETER_ATTR_,RESULT_KEY_);
ATTR_:= 'PRINTER_ID'||CHR(31)||PRINTER_ID_||CHR(30)
||'SETTINGS'||CHR(31)||'!FNDINF.SEND_PDF
$SEND_PDF=TRUE
$SEND_PDF_TO=gerrard.pierce@unipart.com
$APPLY_DEFAULTS=FALSE
!PDF
$PDF_ARCHIVING=TRUE
$PDF_EVENT_PARAM_1=
$PDF_EVENT_PARAM_2='||myline.vendor_no||'
$PDF_EVENT_PARAM_3='||myline.contract||'
$PDF_EVENT_PARAM_4=
$PDF_EVENT_PARAM_5=IFS APPLICATIONS
$PDF_EVENT_PARAM_6='||myline.order_no||'
$REPLY_TO_USER=IFSAPP'||CHR(30);
PRINT_JOB_API.NEW(PRINT_JOB_ID_,ATTR_);
CLIENT_SYS.ADD_TO_ATTR('PRINT_JOB_ID',PRINT_JOB_ID_,INSTANCE_ATTR_);
CLIENT_SYS.ADD_TO_ATTR('RESULT_KEY',RESULT_KEY_,INSTANCE_ATTR_);
PRINT_JOB_CONTENTS_API.NEW_INSTANCE(INSTANCE_ATTR_);
PRINT_JOB_API.PRINT(PRINT_JOB_ID_);
END;

 


Hi another dimension in this topic,  attach Document management documents to outgoing PDF reports. The main purpose is to attach document(s) to Purchase  Order and Customer Order  for detail tech documents and / or general terms and condition.

 

This has already been implemented as customization at some customers, but it would be very helpful if it is included into Core.

 

 


After digging around in the Server Trace tab of Debug Console (after reading this thread) I have a working solution:

First, create the PDF Parameters but including SEND_PDF and SEND_PDF_TO ...

DECLARE
P0_ VARCHAR2(32000) :=
'SEND_PDF'||CHR(31)||'TRUE'||CHR(30)||
'SEND_PDF_TO'||CHR(31)||'user.name@domain.com'||CHR(30)||
'PDF_ARCHIVING'||CHR(31)||'TRUE'||CHR(30)||
'PDF_EVENT_PARAM_1'||CHR(31)||''||CHR(30)||
'PDF_EVENT_PARAM_2'||CHR(31)||VENDOR_NO||CHR(30)||
'PDF_EVENT_PARAM_3'||CHR(31)||CONTRACT||CHR(30)||
'PDF_EVENT_PARAM_4'||CHR(31)||''||CHR(30)||
'PDF_EVENT_PARAM_5'||CHR(31)||'User Name'||CHR(30)||
'PDF_EVENT_PARAM_6'||CHR(31)||ORDER_NO||CHR(30)||
'REPLY_TO_USER'||CHR(31)||'USER_ID'||CHR(30);
P1_ VARCHAR2(32000) := ORDER_NO;
P2_ VARCHAR2(32000) := '';
P3_ VARCHAR2(32000) := '*';
P4_ VARCHAR2(32000) := CONTRACT;
P5_ VARCHAR2(32000) := NULL;
P6_ VARCHAR2(32000) := VENDOR_NO;
BEGIN
IFSAPP.PURCHASE_ORDER_API.GENERATE_PDF_PARAMETERS (P0_ , P1_ , P2_ , P3_ , P4_ , P5_ , P6_ );
END;

Then run the Print Job code, modified (from the code shown in this thread) to include the Purchase Order Report requirements ...

DECLARE
LAYOUT_NAME_ VARCHAR(2000):='PURCHASEORDERPRINTREP.RDL';
REPORT_ID_ VARCHAR2(2000):= 'PURCHASE_ORDER_PRINT_REP';
REPORT_ATTR_ VARCHAR2(2000);
PARAMETER_ATTR_ VARCHAR2(2000);
DISTRIBUTION_LIST_ VARCHAR2(2000):= '';
INSTANCE_ATTR_ VARCHAR2(2000);
PRINT_JOB_ID_ VARCHAR2(2000);
PRINT_ATTR_ VARCHAR2(2000);
PRINTER_ID_ VARCHAR2(2000):= 'PDF_PRINTER';
PUR_ORDER_PRINT_OPTION_ VARCHAR(2000) := 'Order';
ORDER_NO_ VARCHAR2(2000):= ORDER_NO;
RESULT_KEY_ VARCHAR2(2000);
ATTR_ VARCHAR2(2000);
BEGIN
REPORT_ATTR_:= 'REPORT_ID'||CHR(31)||'PURCHASE_ORDER_PRINT_REP'||CHR(30)||'LAYOUT_NAME'||CHR(31)||'PURCHASEORDERPRINTREP.RDL'||CHR(30);
PARAMETER_ATTR_:= 'ORDER_NO_LIST'||CHR(31)||ORDER_NO_||CHR(30)||'PUR_ORDER_PRINT_OPTION'||CHR(31)||PUR_ORDER_PRINT_OPTION_||CHR(30);
ARCHIVE_API.NEW_CLIENT_REPORT(RESULT_KEY_, REPORT_ATTR_, PARAMETER_ATTR_, DISTRIBUTION_LIST_, PRINT_ATTR_);
ARCHIVE_API.GET_INFO(INSTANCE_ATTR_,PARAMETER_ATTR_,RESULT_KEY_);
ATTR_:= 'PRINTER_ID'||CHR(31)||PRINTER_ID_||CHR(30);
PRINT_JOB_API.NEW(PRINT_JOB_ID_,ATTR_);
CLIENT_SYS.ADD_TO_ATTR('PRINT_JOB_ID',PRINT_JOB_ID_,INSTANCE_ATTR_);
CLIENT_SYS.ADD_TO_ATTR('RESULT_KEY',RESULT_KEY_,INSTANCE_ATTR_);
PRINT_JOB_CONTENTS_API.NEW_INSTANCE(INSTANCE_ATTR_);
PRINT_JOB_API.PRINT(PRINT_JOB_ID_);
END;

This process created the Report Archive, the PDF Archive and emails the PDF to the recipient.

The downside of using this method is not being able to control the text or layout in the email ...

 

Hi will this work with a Crystal report rather than a report designer layout? 
 

thanks 


This code can be run to both generate the PDF parameters and send the PDF in one hit, to either negate the need to create the PDF parameters or to override the existing PDF parameters. Note the expansion of the ATTR_ data.

Now it would be nice to be able to change the email subject and body.

DECLARE
LAYOUT_NAME_ VARCHAR(2000):='PurchaseOrderPrintRep.rdl';
REPORT_ID_ VARCHAR2(2000):= 'PURCHASE_ORDER_PRINT_REP';
REPORT_ATTR_ VARCHAR2(2000):= '';
PARAMETER_ATTR_ VARCHAR2(2000):= '';
DISTRIBUTION_LIST_ VARCHAR2(2000):= '';
INSTANCE_ATTR_ VARCHAR2(2000):= '';
PRINT_JOB_ID_ VARCHAR2(2000):= '';
PRINT_ATTR_ VARCHAR2(2000):= '';
PRINTER_ID_ VARCHAR2(2000):= 'PDF_PRINTER';
PUR_ORDER_PRINT_OPTION_ VARCHAR(2000) := 'Order';
--PUR_ORDER_PRINT_OPTION_ VARCHAR(2000) := 'Order Work Copy';
ORDER_NO_ VARCHAR2(2000):= ORDER_NO;
RESULT_KEY_ VARCHAR2(2000):= '';
ATTR_ VARCHAR2(2000):= '';
BEGIN
REPORT_ATTR_:= 'REPORT_ID'||CHR(31)||'PURCHASE_ORDER_PRINT_REP'||CHR(30)||'LAYOUT_NAME'||CHR(31)||'PurchaseOrderPrintRep.rdl'||CHR(30);
PARAMETER_ATTR_:= 'ORDER_NO_LIST'||CHR(31)||ORDER_NO_||CHR(30)||'PUR_ORDER_PRINT_OPTION'||CHR(31)||PUR_ORDER_PRINT_OPTION_||CHR(30);
ARCHIVE_API.NEW_CLIENT_REPORT(RESULT_KEY_, REPORT_ATTR_, PARAMETER_ATTR_, DISTRIBUTION_LIST_, PRINT_ATTR_);
ARCHIVE_API.GET_INFO(INSTANCE_ATTR_,PARAMETER_ATTR_,RESULT_KEY_);
ATTR_:= 'PRINTER_ID'||CHR(31)||PRINTER_ID_||CHR(30)
||'SETTINGS'||CHR(31)||'!FNDINF.SEND_PDF
$SEND_PDF=TRUE
$SEND_PDF_TO=gerrard.pierce@unipart.com
$APPLY_DEFAULTS=FALSE
!PDF
$PDF_ARCHIVING=TRUE
$PDF_EVENT_PARAM_1=
$PDF_EVENT_PARAM_2='||myline.vendor_no||'
$PDF_EVENT_PARAM_3='||myline.contract||'
$PDF_EVENT_PARAM_4=
$PDF_EVENT_PARAM_5=IFS APPLICATIONS
$PDF_EVENT_PARAM_6='||myline.order_no||'
$REPLY_TO_USER=IFSAPP'||CHR(30);
PRINT_JOB_API.NEW(PRINT_JOB_ID_,ATTR_);
CLIENT_SYS.ADD_TO_ATTR('PRINT_JOB_ID',PRINT_JOB_ID_,INSTANCE_ATTR_);
CLIENT_SYS.ADD_TO_ATTR('RESULT_KEY',RESULT_KEY_,INSTANCE_ATTR_);
PRINT_JOB_CONTENTS_API.NEW_INSTANCE(INSTANCE_ATTR_);
PRINT_JOB_API.PRINT(PRINT_JOB_ID_);
END;

 

Hi,

I use above  code in IFS 10 Update 8,  and called it from custom menu (Request for order quotation form, supplier tab  with following parameters:   LAYOUT_NAME_  = ‘QuotationRep.rdl’
and   ‘REPORT_ID_  QUOTATION_REP’ 

It’s successfully worked and Print Job created in Print Queue.
But it's status always is waiting and doesn't change.


Hi @ChanakaAmarasekara ,

Can we provide the name of the pdf that will be generated through event actions?

 

I am looking to do is rename the PDF attachment on the email from IFS internal numbering to an invoice number or order number.

This is possible using report rules. If this is impossible in event actions, can we link the event action with the report rule?


Hi,

The event should take the file name you pass as the attachment name (&PDF_NAME in the event), if you send the value of the file name that you require in the ‘PDF_FILE_NAME’ attribute parameter add to the attribute string along with the other event parameters such as PDF_EVENT_PARAM_* in your code.

Regards,

Chanaka


Hi,

Many thanks for the above instructions.

We have successfully implemented the print purchase order event on Purchase Order Release.

However, we also have a PDF_REPORT_CREATED event that is responsible in sending the mail once the purchase order has been printed.

Individually these events work.

  • Release PO will trigger the event to Print.
  • RMD Print PO will trigger the event to email.

But not in a fully automated sequence. Any idea as to why?

Thanks

Dominik


Hi another dimension in this topic,  attach Document management documents to outgoing PDF reports. The main purpose is to attach document(s) to Purchase  Order and Customer Order  for detail tech documents and / or general terms and condition.

 

This has already been implemented as customization at some customers, but it would be very helpful if it is included into Core.

 

 

Hi @jolnse,

Were you able to implement this, to attach the Document Management docs to the PDF?

Thanks in advance!


Hi another dimension in this topic,  attach Document management documents to outgoing PDF reports. The main purpose is to attach document(s) to Purchase  Order and Customer Order  for detail tech documents and / or general terms and condition.

 

This has already been implemented as customization at some customers, but it would be very helpful if it is included into Core.

 

 

Hi @jolnse,

Were you able to implement this, to attach the Document Management docs to the PDF?

Thanks in advance!

 

This is quite easy to do as long as you use PLSQL Blocks on the event action, or more likely, a custom PLSQL method being called by the event action (so that you can debug it and test it easier).

 

It won’t be the same added to the SAME pdf, but the email going out will contain multiple pdfs

 

Can’t do it as a straight “Mail” event action type though.

 

I can share PLSQL Code snippets of how to create the attachments to the email if you’re interested.

 

 


Hi another dimension in this topic,  attach Document management documents to outgoing PDF reports. The main purpose is to attach document(s) to Purchase  Order and Customer Order  for detail tech documents and / or general terms and condition.

 

This has already been implemented as customization at some customers, but it would be very helpful if it is included into Core.

 

 

Hi @jolnse,

Were you able to implement this, to attach the Document Management docs to the PDF?

Thanks in advance!

 

This is quite easy to do as long as you use PLSQL Blocks on the event action, or more likely, a custom PLSQL method being called by the event action (so that you can debug it and test it easier).

 

It won’t be the same added to the SAME pdf, but the email going out will contain multiple pdfs

 

Can’t do it as a straight “Mail” event action type though.

 

I can share PLSQL Code snippets of how to create the attachments to the email if you’re interested.

 

 

Hi @jolnse,

It would be great if you could share the code snippets you used.

 

Thanks in advance!

Mounika


Hi another dimension in this topic,  attach Document management documents to outgoing PDF reports. The main purpose is to attach document(s) to Purchase  Order and Customer Order  for detail tech documents and / or general terms and condition.

 

This has already been implemented as customization at some customers, but it would be very helpful if it is included into Core.

 

 

Hi @jolnse,

Were you able to implement this, to attach the Document Management docs to the PDF?

Thanks in advance!

 

This is quite easy to do as long as you use PLSQL Blocks on the event action, or more likely, a custom PLSQL method being called by the event action (so that you can debug it and test it easier).

 

It won’t be the same added to the SAME pdf, but the email going out will contain multiple pdfs

 

Can’t do it as a straight “Mail” event action type though.

 

I can share PLSQL Code snippets of how to create the attachments to the email if you’re interested.

 

 

Hi @jolnse,

It would be great if you could share the code snippets you used.

 

Thanks in advance!

Mounika

 

 

Here’s a few examples. The implicit cursors would need to be modified to grab the relevant files,  based for instance on the connected objects table in the Document Management LU.

 

At the moment the implicit cursor for Document Management is set to retrieve only released documents where the doc_type is original (meaning sending the original document and not its viewable transformation. For instance Visio files get transformed as PDF files for viewing so that people without Visio Licenses can still view the document).

 

The snippets include cursors to grab from Document Mangement, Media Files, and Report Archive (so the pdf that gets printed when you print a report).

 

declare


attachments_ ifsapp.Command_sys.attachment_arr;

attachment_ CLOB;

begin

-- Doc Man
for doc_man_rec_ in (

select i.doc_class, i.doc_no, i.doc_sheet, i.doc_rev, e.file_no, e.user_file_name, e.doc_type, s.file_data
from ifsapp.doc_issue_tab i
left join ifsapp.edm_file_tab e on e.doc_class = i.doc_class and e.doc_no = i.doc_no and e.doc_rev = i.doc_rev and e.doc_sheet = i.doc_sheet
left join ifsapp.edm_file_storage_tab s on s.doc_class = i.doc_class and s.doc_no = i.doc_no and s.doc_rev = i.doc_rev and s.doc_sheet = i.doc_sheet and s.doc_type = e.doc_type
where i.rowstate = 'Released' and s.doc_type = 'ORIGINAL'
fetch first 1 rows only

) loop



ifsapp.command_sys.add_attachment(attachments_ => attachments_,
filename_ => doc_man_rec_.user_file_name,
attachment_ => doc_man_rec_.file_data);

end loop;

-- Media

for media_item_rec_ in (

select m.item_id, m.media_file, m.media_object
from ifsapp.media_item_tab m
left join ifsapp.media_library_item_tab il on il.item_id = m.item_id
left join ifsapp.media_library_tab l on l.library_id = il.library_id
fetch first 1 rows only

) LOOP

ifsapp.command_sys.add_attachment(attachments_ => attachments_,
filename_ => media_item_rec_.item_id||'_'||media_item_rec_.media_file,
attachment_ => media_item_rec_.media_object);


END LOOP;


-- Report Archive
for report_archive_rec_ in (

select t.result_key, t.print_job_id, t.file_name, t.pdf
from ifsapp.pdf_archive_tab t
fetch first 1 rows only

) LOOP

ifsapp.command_sys.add_attachment(attachments_ => attachments_,
filename_ => report_archive_rec_.file_name,
attachment_ => report_archive_rec_.pdf);


END LOOP;



ifsapp.Command_sys.mail(sender_ => 'yourmailsender',
from_ => 'your.mail@sender.com',
to_list_ => 'recipient@email.com',
cc_list_ => '',
bcc_list_ => '',
subject_ => 'Test Multiple Attachments',
text_ => 'Here are Multiple Attachments',
attachments_ => attachments_,
mail_sender_ => 'MAIL_SENDER1');

end;

 

Any developper should be able to modifiy these to their hearts content to only grab the relevant documents, for example the documents attached to the Purchase Order Header of a particular Document Class or any other sort of requirement.


Hi another dimension in this topic,  attach Document management documents to outgoing PDF reports. The main purpose is to attach document(s) to Purchase  Order and Customer Order  for detail tech documents and / or general terms and condition.

 

This has already been implemented as customization at some customers, but it would be very helpful if it is included into Core.

 

 

Hi @jolnse,

Were you able to implement this, to attach the Document Management docs to the PDF?

Thanks in advance!

 

This is quite easy to do as long as you use PLSQL Blocks on the event action, or more likely, a custom PLSQL method being called by the event action (so that you can debug it and test it easier).

 

It won’t be the same added to the SAME pdf, but the email going out will contain multiple pdfs

 

Can’t do it as a straight “Mail” event action type though.

 

I can share PLSQL Code snippets of how to create the attachments to the email if you’re interested.

 

 

Hi @jolnse,

It would be great if you could share the code snippets you used.

 

Thanks in advance!

Mounika

 

 

Here’s a few examples. The implicit cursors would need to be modified to grab the relevant files,  based for instance on the connected objects table in the Document Management LU.

 

At the moment the implicit cursor for Document Management is set to retrieve only released documents where the doc_type is original (meaning sending the original document and not its viewable transformation. For instance Visio files get transformed as PDF files for viewing so that people without Visio Licenses can still view the document).

 

The snippets include cursors to grab from Document Mangement, Media Files, and Report Archive (so the pdf that gets printed when you print a report).

 

declare


attachments_ ifsapp.Command_sys.attachment_arr;

attachment_ CLOB;

begin

-- Doc Man
for doc_man_rec_ in (

select i.doc_class, i.doc_no, i.doc_sheet, i.doc_rev, e.file_no, e.user_file_name, e.doc_type, s.file_data
from ifsapp.doc_issue_tab i
left join ifsapp.edm_file_tab e on e.doc_class = i.doc_class and e.doc_no = i.doc_no and e.doc_rev = i.doc_rev and e.doc_sheet = i.doc_sheet
left join ifsapp.edm_file_storage_tab s on s.doc_class = i.doc_class and s.doc_no = i.doc_no and s.doc_rev = i.doc_rev and s.doc_sheet = i.doc_sheet and s.doc_type = e.doc_type
where i.rowstate = 'Released' and s.doc_type = 'ORIGINAL'
fetch first 1 rows only

) loop



ifsapp.command_sys.add_attachment(attachments_ => attachments_,
filename_ => doc_man_rec_.user_file_name,
attachment_ => doc_man_rec_.file_data);

end loop;

-- Media

for media_item_rec_ in (

select m.item_id, m.media_file, m.media_object
from ifsapp.media_item_tab m
left join ifsapp.media_library_item_tab il on il.item_id = m.item_id
left join ifsapp.media_library_tab l on l.library_id = il.library_id
fetch first 1 rows only

) LOOP

ifsapp.command_sys.add_attachment(attachments_ => attachments_,
filename_ => media_item_rec_.item_id||'_'||media_item_rec_.media_file,
attachment_ => media_item_rec_.media_object);


END LOOP;


-- Report Archive
for report_archive_rec_ in (

select t.result_key, t.print_job_id, t.file_name, t.pdf
from ifsapp.pdf_archive_tab t
fetch first 1 rows only

) LOOP

ifsapp.command_sys.add_attachment(attachments_ => attachments_,
filename_ => report_archive_rec_.file_name,
attachment_ => report_archive_rec_.pdf);


END LOOP;



ifsapp.Command_sys.mail(sender_ => 'yourmailsender',
from_ => 'your.mail@sender.com',
to_list_ => 'recipient@email.com',
cc_list_ => '',
bcc_list_ => '',
subject_ => 'Test Multiple Attachments',
text_ => 'Here are Multiple Attachments',
attachments_ => attachments_,
mail_sender_ => 'MAIL_SENDER1');

end;

 

Any developper should be able to modifiy these to their hearts content to only grab the relevant documents, for example the documents attached to the Purchase Order Header of a particular Document Class or any other sort of requirement.

Hi @SimonTestard ,

This is beautiful. Thank you for sharing :)

This is for attaching the documents from Attachments. Have you ever tried to print these attachments along with the Order Report?
For example, when user prints the PO report, then we must also automatically print the documents attached to the PO header or lines.

 


Hey,

 

It would be done with this part of the cursor:

 

-- Doc Man
for doc_man_rec_ in (

select i.doc_class, i.doc_no, i.doc_sheet, i.doc_rev, e.file_no, e.user_file_name, e.doc_type, s.file_data
from ifsapp.doc_issue_tab i
left join ifsapp.edm_file_tab e on e.doc_class = i.doc_class and e.doc_no = i.doc_no and e.doc_rev = i.doc_rev and e.doc_sheet = i.doc_sheet
left join ifsapp.edm_file_storage_tab s on s.doc_class = i.doc_class and s.doc_no = i.doc_no and s.doc_rev = i.doc_rev and s.doc_sheet = i.doc_sheet and s.doc_type = e.doc_type
where i.rowstate = 'Released' and s.doc_type = 'ORIGINAL'
fetch first 1 rows only

) loop

 

 

When you get the Purchase Order to Print, through the PDF_REPORT_CREATED event, you’ll get several parameters like result_key, print_job_id, etc.

 

From those parameters, you can retrieve the Purchase Order_No

 

Typically I do it like this:

 

From the Order No, you can then check documents attached to header/lines through the DOC_REFERENCE_OBJECT view/lu, based on the KeyRef:

Example here is for PurchaseRequisition but can be changed to PurchaseOrder or anything else to grab any attachment to any IFS Object.

 

This will give you the Document Keys to use to filter in the main cursor to grab documents attached to a given PO Line/Header

 

 


(Note that the above example is using the view doc_reference_object but any developper should likely use the underlying table (doc_reference_object_tab) to avoid any docman permission conflicts when trying to retrieve these attachments, as otherwise your attachments might or might not be found depending on whether the permissions the IFS CONNECT user has to access specific documents. This is because the PDF_CREATED_EVENT is actually executed by IFS.CONNECT, not by the user who actually requested the print), so either use the table or make sure IFS.CONNECT has a DOCMAN Administrator system privileges)


Hey,

 

It would be done with this part of the cursor:

 

-- Doc Man
for doc_man_rec_ in (

select i.doc_class, i.doc_no, i.doc_sheet, i.doc_rev, e.file_no, e.user_file_name, e.doc_type, s.file_data
from ifsapp.doc_issue_tab i
left join ifsapp.edm_file_tab e on e.doc_class = i.doc_class and e.doc_no = i.doc_no and e.doc_rev = i.doc_rev and e.doc_sheet = i.doc_sheet
left join ifsapp.edm_file_storage_tab s on s.doc_class = i.doc_class and s.doc_no = i.doc_no and s.doc_rev = i.doc_rev and s.doc_sheet = i.doc_sheet and s.doc_type = e.doc_type
where i.rowstate = 'Released' and s.doc_type = 'ORIGINAL'
fetch first 1 rows only

) loop

 

 

When you get the Purchase Order to Print, through the PDF_REPORT_CREATED event, you’ll get several parameters like result_key, print_job_id, etc.

 

From those parameters, you can retrieve the Purchase Order_No

 

Typically I do it like this:

 

From the Order No, you can then check documents attached to header/lines through the DOC_REFERENCE_OBJECT view/lu, based on the KeyRef:

Example here is for PurchaseRequisition but can be changed to PurchaseOrder or anything else to grab any attachment to any IFS Object.

 

This will give you the Document Keys to use to filter in the main cursor to grab documents attached to a given PO Line/Header

 

 

Hi @SimonTestard 

This code is to fetch the documents. But how can we send them to the printer?
For example, as soon as we send the PO report to physical printer, then we should also send these documents to print immediately along with the report. Is this possible?


Reply