# Automatically Re-Enable APEX Automations After Deployment

# Introduction

As you may know, when you deploy an APEX Application, APEX automatically disables all of the APEX Automations associated with that Application. This is perfectly fine in many scenarios, but when deploying to production, you nearly always want to restart all your Automations following the deployment. This post will describe two options for automating and re-enabling APEX Automations following a deployment.

# Post Deployment SQL Script

This option involves creating a SQL script to loop through all Automations related to the APEX Application and re-activate them.

```sql
DECLARE
  CURSOR cr_app_automations IS
    SELECT app.application_id, app.workspace, atm.static_id
    FROM   apex_appl_automations atm
    ,      apex_applications     app
    WHERE  app.application_id = atm.application_id
    AND    app.alias          = 'BACKGROUND-APEX';
BEGIN
  -- Loop through all Automations for the Application.
  FOR r_app_automation IN cr_app_automations LOOP
    -- Set the Workspace / Security Group for the Application.
    apex_util.set_security_group_id 
      (p_security_group_id => apex_util.find_security_group_id 
                                (p_workspace => r_app_automation.workspace));
    -- Enable the Automation.
    apex_automation.enable
     (p_application_id => r_app_automation.application_id,
      p_static_id      => r_app_automation.static_id);
  END LOOP;
END;
```

The above script should be run after the APEX Application Deployment.

# Supporting Objects Install Script

Another approach is to include the script as a Supporting Object Script, which will run automatically every time the Application is deployed.

Navigate to Application &gt; Supporting Objects &gt; Scripts &gt; Install

![Supporting Objects - Enable Automations Step 1](https://cdn.hashnode.com/res/hashnode/image/upload/v1737398375625/d9d359c4-ad81-4fcf-aab8-4f97d2af7046.png align="center")

Click the **Create** button:

![Supporting Objects - Enable Automations Step 2](https://cdn.hashnode.com/res/hashnode/image/upload/v1737398441384/c752aeac-3991-48cf-8478-e3e829ded951.png align="center")

Select ‘Create from Scratch’, and then click the **Next** Button:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1737398504552/4ffb4e26-303c-4a73-b213-7f4eda53be21.png align="center")

Enter a name for the Script and click the **Next** button:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1737398550511/7f2a9b5c-8607-49dc-b59c-de96628398c9.png align="center")

Copy and Paste the same script as option one above, and click the **Create** button.

## APEX Builder Application Import

The next time you import the APEX Application, you will get the Option to **Install Supporting Objects**. Click this button to run the script to re-activate your APEX Automations.

![Supporting Objects - App Install Step 1](https://cdn.hashnode.com/res/hashnode/image/upload/v1737398687814/dd2bc0e0-700e-46c9-a343-a9fae1406553.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1737398749162/d574becc-fe8b-4d10-bfd4-9753cf519339.png align="center")

After this step is complete, you can check the status of the install scripts by clicking the **Install Summary** button.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1737398804441/6fad32e9-64fd-4326-a085-bbed1d4de1bf.png align="center")

If you check the status of the Automations in the newly installed App, they should all be **Active**.

![Supporting Objects - App Install Step 4](https://cdn.hashnode.com/res/hashnode/image/upload/v1737398832339/9849f963-9c1d-4496-96ca-c75d32cdfaf8.png align="center")

## Command Line Import

If you import your app via the command line, you can call it [apex\_application\_install.set\_auto\_install\_sup\_obj](https://docs.oracle.com/en/database/oracle/apex/24.1/aeapi/SET_AUTO_INSTALL_SUP_OBJ-Procedure.html) API to tell APEX to automatically run the supporting object scripts after the app has been imported.

```sql
BEGIN
  apex_application_install.set_auto_install_sup_obj (p_auto_install_sup_obj => true);
END;
/
@f100.sql
```

# Conclusion

This was a quick tip that will hopefully save time and prevent you from manually re-activating your APEX Automations after deploying an Application.
