7. Manage an Action File Export via Mail¶
A mail action export makes it possible to send data of a view or table via mail as soon as some application status has been reached.
Configure a proper e-mail body in ADM_MAIL_PARAMS first using API_REDADM.SET_MAIL_PARAM.
make sure that an application and proper export definitions already exist:
7.1. Add a Mail Action Export to an Application¶
Use the script API_REDADM.ADD_APP_ACT_EXP_MAIL.
The example below creates an action (of type ‘export_mail’) which is triggered when the FINAL application status switches to FINISHED (which means that all depending tables have reached the status ‘FINISHED’)i with a delay of 60 sec. The action will create a file based on the export definition ‘test_exp’
for the BDate 2024-08-01
a mail template called ‘app_notify_final’ will be used
the mail will be sent to ‘testuser@test.at’
the mail will not be sent once more for the same BDate if on of the components woulkd have been reloaded for some reason The action will not be fired if a BDate swiches to ‘FINISHED’ which is older than 3 days from today.
Example
1EXECUTE SCRIPT API_REDADM.ADD_APP_ACT_EXP_MAIL(
2 'test_app' -- p_app_name
3 ,'tst_act' -- p_action_name
4 ,'test action' -- p_description
5 ,'FINAL' -- p_finished_type
6 ,'test_exp' -- p_exp_name
7 ,'app_notify_final' -- p_mail_template
8 ,'testuser@test.at' -- p_recipients
9 ,'2024-08-01' -- p_valid_from_bdate
10 ,false -- p_active
11 ,true -- p_run_once
12 ,60 -- p_run_delay
13 ,3 -- p_bdate_retention
14);
After issuing this command a new entry is added to 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 |
exp_mail |
test_exp |
app_notify_final |
2024-08-01 |
false |
true |
60 |
3 |
7.2. Modify a Mail Action Export¶
For modification use the script API_REDADM.MODIFY_APP_ACT_EXP_MAIL. Providing NULL leaves the parameters as is, while a blank (’ ‘) restores the default value.
In the example below only the value for the mail template should be changed, while the rest remains the same. 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.
Example
1EXECUTE SCRIPT API_REDADM.MODIFY_APP_ACT_EXP_MAIL(
2 'test_app' -- p_app_name
3 ,'tst_act' -- p_action_name
4 ,null -- p_description
5 ,null -- p_finished_type
6 ,null -- p_exp_name
7 ,'test' -- p_mail_template
8 ,null -- p_recipients
9 ,null -- p_valid_from_bdate
10 ,null -- p_active
11 ,null -- p_run_once
12 ,null -- p_run_delay
13 ,null -- p_bdate_retention
14);
After issuing this command the entry in 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 |
exp_mail |
test_exp |
test |
2024-08-01 |
false |
true |
60 |
3 |
7.3. Remove a Mail Action Export¶
Remove any application action using the script API_REDADM.REMOVE_APP_ACTION.
Example
1EXECUTE SCRIPT API_REDADM.REMOVE_APP_ACTION(
2 'test_app' -- p_app_name
3 ,'tst_act' -- p_action_name
4);
After having issued the command above the entry in RED_APP_ACTIONS will have been removed.