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.
Page 1 / 2
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?
@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.
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.
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.
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 ...
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.
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 ...
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.
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
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
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
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
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:
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:
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?