APEX Office Print save file into database tip
Additional parameters in aop_store_document & send_email_prc
How to add additional page parameters to your call?
Very simple ask - we want to save AOP file printed by user into database. I am sure most have by now tried or at least checked out an AOP Sample application.
Point of interest for us is Email attachment example and we will try to build on it.
Adding code snippet for the ease of reading this post.
Idea is we want to reuse code in aop_store_document or send_email_prc procedures with one exception we want to pass in several page items from APEX page to be able to do something along these lines
insert into AA_DOCUMENT (file_type_id, file_name, file_mimetype, file_blob, user_comments, status, .... )
Looking at these procedures most of our work was done by AOP team which is great p_output_blog will be holding the file generated by our users.
Challenge is that AOP is expecting to get exaclty this procedure signatures where we can additionaly add custom parameters defaulted to something but still how do we send something that is dynamic at run time. As the only input we can give is controlled by
With no ability to define what these additional inputs are like PX_COMMENT or PX_STATUS.
So how do we do this?
First that crossed my mind was to tackle it full on with PLSQL direct call to AOP
which we could also do but then I said wait sure there is an APEX build-in way to help me with this.
Of course the good old friend called APEX_COLLECTION saves the day again here.
Why? Pretty much we can reuse standard AOP call that my report DA is doing anyway and add flavors as needed.
All that we are missing now is to add similar PLSQL before APEX office Print (AOP) - DA [Plugin] action that will set up data for me.
We can do as many page items here and then it is easy to loop through a collection and insert data from it:
Of course as always we can tackle this from many angles but hoping this will also help save some time.