Skip to main content
Solved

Add Purchase Order Attachments to the Same Email , When Print Order


Forum|alt.badge.img+15

Hello Everyone,

 

There is a requirement to send Attachments  with the same email of the Purchase Order’s Print Order...

The mail should contain the attachments of the Purchase Order as well as the Purchase Order report.

This should be happen only if the attachments are in specific document classes eg: 4600 - 4699.

This should be work in Aurena as well.

 

Please let me know if you have any idea of how to do this.

 

 

Many Thanks,

Denuka

Best answer by Asela Munasinghe

@MitDenukN Please see if this thread helps answer your question. 

 

 

View original
Did this topic help you find an answer to your question?

10 replies

Asela Munasinghe
Superhero (Customer)
Forum|alt.badge.img+21
  • Superhero (Customer)
  • 729 replies
  • Answer
  • September 1, 2021

@MitDenukN Please see if this thread helps answer your question. 

 

 


Forum|alt.badge.img+15
  • Author
  • 276 replies
  • September 1, 2021

Thank you very much @EnzoFerrari .

Thread has given the answer for my question and I will give it a try.

 


Asela Munasinghe
Superhero (Customer)
Forum|alt.badge.img+21

You are welcome @MitDenukN , once you’ve tested it, please keep us posted if it worked


Forum|alt.badge.img+15
  • Author
  • 276 replies
  • September 1, 2021

That code is working and I had to do few modifications to fetch values.
Please find below code to use in PDF_REPORT_CREATED event action:

DECLARE

keyref_     VARCHAR2(4000);
extention_  VARCHAR2(260);

CURSOR get_attachments IS
select a.doc_class, a.doc_no, a.doc_sheet, a.doc_rev, b.doc_type, b.file_no,  b.file_extention, b.file_name 
from doc_reference_object a, edm_file b
where a.lu_name = 'PurchaseOrder'
and b.doc_class = a.doc_class
and b.doc_no = a.doc_no
and b.doc_sheet = a.doc_sheet
and b.doc_rev = a.doc_rev
and a.doc_class between 4600 and 4699
and a.key_ref = keyref_;

download_path_        VARCHAR2(4000) := DOCMAN_DEFAULT_API.Get_Default_Value_('BatchTransferHandler', 'FILE_PATH_FOR_BATCH_TRANSFER');
error_msg_                VARCHAR2(4000); 
attachment_name_   VARCHAR2(4000);
attachments_       VARCHAR2(4000);
xml_               clob;
x_                 xmltype;

order_no_           VARCHAR2(20);
to_user_            VARCHAR2(2000);
from_user_name_     VARCHAR2(200);
supplier_id_        VARCHAR2(200);
subject_            VARCHAR2(32000);
text_                        VARCHAR2(32000);
company_name_      VARCHAR2(100);
company_                VARCHAR2(20);

BEGIN

select x.data 
 into xml_
 from  xml_report_data x 
 where x.result_key= '&RESULT_KEY';

  x_:= xmltype.createxml(xml_);

 SELECT extractvalue(x_, 'PURCHASE_ORDER_PRINT_REP/PO_HEADERS/PO_HEADER/ORDER_NO') INTO order_no_ FROM DUAL;
 SELECT extractvalue(x_, 'PURCHASE_ORDER_PRINT_REP/PO_HEADERS/PO_HEADER/SUPPLIER_NO') INTO supplier_id_ FROM DUAL;

 keyref_ := 'ORDER_NO=' || order_no_  || '^';

FOR rec_ IN get_attachments LOOP

  SELECT
      SUBSTR(rec_.file_name , INSTR(rec_.file_name , '.') + 1) 
  INTO extention_
  FROM dual;

  attachment_name_ := download_path_  ||  'attachment-' || rec_.doc_class || '_' || rec_.doc_no || '.' || extention_;
  error_msg_ := NULL;


Batch_Transfer_Handler_Api.Download_From_Db(error_msg_,
rec_.doc_class,
rec_.doc_no,
rec_.doc_sheet,
rec_.doc_rev,
rec_.doc_type,
rec_.file_no,
attachment_name_);

IF (error_msg_ IS NOT NULL) THEN 
Batch_Transfer_Handler_Api.Download_From_Db(error_msg_,
rec_.doc_class,
rec_.doc_no,
rec_.doc_sheet,
rec_.doc_rev,
'VIEW',
rec_.file_no,
attachment_name_);
END IF;

attachments_ := attachments_ || attachment_name_ || ';';

END LOOP;

  subject_:= 'Purchase Order Report and Attachments';
  text_:= 'Report and Attachments of the Purchase Order are ready.';

  to_user_  := 'test@gmail.com';

    Command_SYS.Mail
    (
       from_user_name_ => from_user_name_,
       to_user_name_   => to_user_ ,
       text_           =>  text_,
       subject_        =>  subject_ ,
       attach_         => attachments_ ||  '&PDF_FILE'
    );

COMMIT;

END; 

 


Forum|alt.badge.img+15
  • Author
  • 276 replies
  • September 1, 2021

But there is another concern, If user enter an email address in Print Dialog Box, recipient will get multiple mails. 

Is there any possibility to modify the Application Message and  attach those attachment to the mail other than using PDF_REPORT_CREATED event action ?

 


Asela Munasinghe
Superhero (Customer)
Forum|alt.badge.img+21

@MitDenukN which IFS version and update are you using? Looks like the event PDF_REPORT_CREATED generating more than 1 email to the recipient is an error in IFS 


Forum|alt.badge.img+15
  • Author
  • 276 replies
  • September 1, 2021

@EnzoFerrari event action PDF_REPORT_CREATED is sending one email and the other email is from Print dialog box’s email. Emails are in different Queues in Application Messages window.

PDF_REPORT_CREATED mail comes under NOTIFICATIONS and the other comes under OUT1.

(It’s IFS Apps 10 UPD12)

From PDF_REPORT_CREATED
From Print Dialog

 


Asela Munasinghe
Superhero (Customer)
Forum|alt.badge.img+21

@MitDenukN apologies for not being able to solve your last query. But I see you have initiated a new thread on that and a few options are suggested there. Hope you will soon get the overall clarification you are seeking. 

happy weekend! 

p.s. For anyone wondering where the new thread is, here’s the link. 

 

 


Forum|alt.badge.img+15
  • Author
  • 276 replies
  • September 10, 2021

@EnzoFerrari That’s all right, thank you for your suggestion and it helped me to implement on PDF_REPORT_CREATED. :blush: And also thanks for attaching the new thread to this.

 

Happy Weekend!


Jonas Feigl
Superhero (Employee)
Forum|alt.badge.img+20
  • Superhero (Employee)
  • 261 replies
  • May 19, 2023

 Please refer and perhaps upvote the following idea: 

https://community.ifs.com/ideas/pdf-inserts-for-docman-attachments-34382

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings