A mail action export makes it possible to send data of a view or table via mail if a specific action occurs.
To be able to add an ‘EXP_MAIL’ action to an application, some mail parameters need to be set first. Either there already are some example e-mail entries or one has to add the e-mail content that should be sent with the file. Adding e-mail content can be done by adding an entry to the REDADM.ADM_MAIL_PARAMS table.
Furthermore one has to create an application, add objects to that application, add an export formatting rule
and create an action export, before following this HowTo Guide any further. These steps have to be taken first, as these are necessary parameters to be able to send an email containing a file with the desired data, if a specific action occurs.
By following the first chapter of each of the HowTo Guides linked below, all necessary parameters will be added to the database.
After creating an application, adding objects to the application, adding a formatting rule, creating an action export and having existing mail parameters, one can combine all these components into one action-application set. This can be done using the script API_REDADM.ADD_APP_ACTION_EXP_MAIL.
For this script all of the parameters are mandatory except for the description of this action. For this example the first variable would be the name of the application, that was created following the first linked HowTo Guide above "Create an Application" and filled with objects following the second linked HowTo Guide "Add objects to an Application". The fifth variable would be the name of the export created following the last linked HowTo Guide "Create an Action Export", using the format created following the third linked HowTo Guide "Add an export formatting rule" and the sixth variable has the value of the ID of the mail template that either already existed or was created earlier in this step. While the fifth variable MUST exist in the APP_ACT_EXPORTS table the sixth variable MUST exist in the ADM_MAIL_PARAMS table for this script to be able to run.
The rest of the variables can be used to give the action a name, to select which status should trigger this action based on the view REDADM, to select the recipients of the mail, how often the action should be executed per day and how many numbers of days are relevant before a trigger is sparked. Furthermore, one can set a delay time, an action execution state and the action's initial execute date.
EXECUTE SCRIPT API_REDADM.ADD_APP_ACT_EXP_MAIL(
'test_app' -- p_app_name
,'tst_act' -- p_action_name
,'test action' -- p_description
,'FINAL' -- p_finished_type
,'test_exp' -- p_exp_name
,'app_notify_final' -- p_mail_template
,'testuser@test.at' -- p_recipients
,'2024-08-01' -- p_valid_from_bdate
,false -- p_active
,true -- p_run_once
,60 -- p_run_delay
,3 -- p_bdate_retention
);
After issuing this command a new entry is added to REDADM.RED_APP_ACTIONS.
app_name | action_ name | description | finished_ type | action_ type | action_ par1 | action_ par2 | action_ par3 | valid_ from_ bdate | active | run_ once | run_ delay | bdate_ retention |
---|---|---|---|---|---|---|---|---|---|---|---|---|
test_app | tst_act | test action | FINAL | export_mail | test_exp | app_ notify_ final | testuser @test.at | 2024-08-01 | false | true | 60 | 3 |
To modify any of the parameters of a mail action export, one only has to provide the exact name of the application and of the action one wants to modifyas well as all new values for the parameters, which are supposed to be changed, and a 'null' for all parameters, which should keep their current value, to the script API_REDADM.MODIFY_APP_ACT_EXP_MAIL.
In the example below only the value for the mail template should be changed, while the rest remains the same. But one has to change that parameter with caution, as only mail templates which already exist in REDADM.ADM_MAIL_PARAMS can be used and the exact ID has to be provided.
EXECUTE SCRIPT API_REDADM.MODIFY_APP_ACT_EXP_MAIL(
'test_app' -- p_app_name
,'tst_act' -- p_action_name
,null -- p_description
,null -- p_finished_type
,null -- p_exp_name
,'test' -- p_mail_template
,null -- p_recipients
,null -- p_valid_from_bdate
,null -- p_active
,null -- p_run_once
,null -- p_run_delay
,null -- p_bdate_retention
);
After issuing this command the entry in REDADM.RED_APP_ACTIONS will have changed as follows.
app_name | action_ name | description | finished_ type | action_ type | action_ par1 | action_ par2 | action_ par3 | valid_ from_ bdate | active | run_ once | run_ delay | bdate_ retention |
---|---|---|---|---|---|---|---|---|---|---|---|---|
test_app | tst_act | test action | FINAL | export_mail | test_exp | test | testuser @test.at | 2024-08-01 | false | true | 60 | 3 |
To remove any application action the script API_REDADM.REMOVE_APP_ACTION can be used. One only has to provide the name of the application the action should be removed from and the action itself.
EXECUTE SCRIPT API_REDADM.REMOVE_APP_ACTION(
'test_app' -- p_app_name
,'tst_act' -- p_action_name
);
After having issued the command above the entry in REDADM.RED_APP_ACTIONS will have been removed.