Solved

EDM File - Attach to email in Routing Address

  • 21 August 2020
  • 9 replies
  • 823 views

Userlevel 2
Badge +7

Hi,

I wanted to enquire if it was possible to create an event that was triggered when a file was stored in EDM (File Repository) and then send an email using IFS Connect Routing Rules/Addresses with the email attached or a path to the file stored in the body of the email?

 

I can see the routing address for email has an attachment name parameter. Is it also possible to pass a TO address to the routing destination dynamically?

icon

Best answer by paul harland 24 August 2020, 17:17

View original

9 replies

Userlevel 7
Badge +24

hi Colin,

does it need to be done using Routing Rules?

it can probably be done, but it’s easier to do it directly within a PL/SQL event action.  We can provide you with an example of code that will do that.

on that note: which version of IFS do you have?

Userlevel 2
Badge +7

Hi @paul harland 

Due to my limited knowledge I find it difficult to work with more complex PL/SQL and have tried such and event action. If it is possible using routing rules that would be useful for me to see. If you can provide an example of using both routing and PL/SQL that would be massively helpful though.

Userlevel 7
Badge +21

Hi @paul harland,

 

We would be interested in seeing how to perform this functionality within PL/SQL event action.  We are using document management heavily and we’ve recently received a request to email any newly attached document in a particular document class to a distribution group.  

 

We are running IFS Application 10 Update 8.

 

Thank you,

William Klotz

Userlevel 7
Badge +24

Hi @paul harland 

Due to my limited knowledge I find it difficult to work with more complex PL/SQL and have tried such and event action. If it is possible using routing rules that would be useful for me to see. If you can provide an example of using both routing and PL/SQL that would be massively helpful though.

ok, i haven’t done it this way before but i gave it a go.  It appears you can populate the TO email address dynamically. 

Put it in the event like this:

(silly example but hopefully you get the idea)

 

Routing Address

Routing Rule

Trigger the event, and i see this application message:

 

Userlevel 2
Badge +7

@paul harland  Thanks for that works perfectly for the sending address! Would you be able to help with an example of how I could add an attachment stored in the EDM repo (File based)?

Userlevel 7
Badge +24

@paul harland  Thanks for that works perfectly for the sending address! Would you be able to help with an example of how I could add an attachment stored in the EDM repo (File based)?

@cwright yep, that’s going to be a lot harder!

IFS uses a format &PDF_FILE when printing reports etc.  So you could start by trying that.  Obviously though, your file may not be a PDF, among other issues.  

You say it’s file based - that makes it harder still (compared to database storage).

Honestly even an experienced analyst would need to spend several hours exploring how that might be done.

A path to the file is going to be somewhat easier because that’s just text that could be generated somehow inside a parameter.

Userlevel 2
Badge +7

@paul harland  Thanks for that works perfectly for the sending address! Would you be able to help with an example of how I could add an attachment stored in the EDM repo (File based)?

@cwright yep, that’s going to be a lot harder!

IFS uses a format &PDF_FILE when printing reports etc.  So you could start by trying that.  Obviously though, your file may not be a PDF, among other issues.  

You say it’s file based - that makes it harder still (compared to database storage).

Honestly even an experienced analyst would need to spend several hours exploring how that might be done.

A path to the file is going to be somewhat easier because that’s just text that could be generated somehow inside a parameter.

Hi @paul harland thanks for the information, is that to say it can only really be achieved using custom PL/SQL packages? If so you would have an example?

Userlevel 7
Badge +24

@cwright @william.klotz 

yes you will get to the answer more quickly using PL/SQL, with the command_sys package.

An example is below - this is not tested so apologies for any small bugs.

 

DECLARE
mailto_ VARCHAR2(800) := 'PAUL@IFS.COM';
mailfrom_ VARCHAR2(800) := 'No_Reply@ifs.com';
file_name_ varchar2(2000);
file_names_ varchar2(2000);
doc_type_ varchar2(2000);
AM Plsqlap_Record_API.type_record_;
f_ varchar2(2000);

doc_class_ VARCHAR2(100) := '&NEW:DOC_CLASS';
doc_no_ VARCHAR2(100) := '&NEW:DOC_NO';
doc_sheet_ VARCHAR2(100) := '&NEW:DOC_SHEET';
doc_rev_ VARCHAR2(100) := '&NEW:DOC_REV';

BEGIN

EDM_FILE_API.REFERENCE_EXIST(F_,doc_class_, doc_no_, doc_sheet_, doc_rev_,'VIEW');
IF F_ = 'TRUE' THEN
  doc_type_ := 'VIEW';
ELSE
  doc_type_ := 'ORIGINAL';
END IF;

file_name_ := EDM_FILE_API.GET_NEW_LOCAL_FILE_NAME(doc_class_, doc_no_, doc_sheet_, doc_rev_,doc_type_,'1');

AM := 
Plsqlap_Record_API.New_record('DOCUMENT_FILE_DATA');
Plsqlap_Record_API.Set_Value (AM, 'DOC_CLASS', doc_class_, Plsqlap_Record_API.dt_Text_Key, FALSE);
Plsqlap_Record_API.Set_Value (AM, 'DOC_NO',    doc_no_, Plsqlap_Record_API.dt_Text_Key, FALSE);
Plsqlap_Record_API.Set_Value (AM, 'DOC_SHEET', doc_sheet_, Plsqlap_Record_API.dt_Text_Key, FALSE);
Plsqlap_Record_API.Set_Value (AM, 'DOC_REV',   doc_rev_, Plsqlap_Record_API.dt_Text_Key, FALSE);
Plsqlap_Record_API.Set_Value (AM, 'DOC_TYPE',  doc_type_, Plsqlap_Record_API.dt_Text_Key, FALSE);
Plsqlap_Record_API.Set_Value (AM, 'FILE_NO', '1', Plsqlap_Record_API.dt_Integer, FALSE);
Plsqlap_Record_API.Set_Value (AM, 'LOCAL_FILE_NAME',file_name_, Plsqlap_Record_API.dt_Text_Key, FALSE);
Plsqlap_Server_API.Invoke_Record_Impersonate('BatchTransferHelper', 'readFromDatabase', AM);

COMMAND_SYS.MAIL(
FROM_USER_NAME_ => mailfrom_,
TO_USER_NAME_ => mailto_,
TEXT_ => 'Please find attached document',
SUBJECT_ => 'document attached',
ATTACH_ =>  file_name_ );

END; 

Userlevel 7
Badge +30

Related to this: have you looked into the Document Distribution functionality? It has ways to notify users who are interested in/subscribing to, certain documents.

 

Reply